File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,35 @@ pub fn yield_now() {
321
321
}
322
322
323
323
/// Determines whether the current thread is unwinding because of panic.
324
+ ///
325
+ /// # Examples
326
+ ///
327
+ /// ```rust,should_panic
328
+ /// use std::thread;
329
+ ///
330
+ /// struct SomeStruct;
331
+ ///
332
+ /// impl Drop for SomeStruct {
333
+ /// fn drop(&mut self) {
334
+ /// if thread::panicking() {
335
+ /// println!("dropped while unwinding");
336
+ /// } else {
337
+ /// println!("dropped while not unwinding");
338
+ /// }
339
+ /// }
340
+ /// }
341
+ ///
342
+ /// {
343
+ /// print!("a: ");
344
+ /// let a = SomeStruct;
345
+ /// }
346
+ ///
347
+ /// {
348
+ /// print!("b: ");
349
+ /// let b = SomeStruct;
350
+ /// panic!()
351
+ /// }
352
+ /// ```
324
353
#[ inline]
325
354
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
326
355
pub fn panicking ( ) -> bool {
You can’t perform that action at this time.
0 commit comments