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() {
321321}
322322
323323/// 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+ /// ```
324353#[ inline]
325354#[ stable( feature = "rust1" , since = "1.0.0" ) ]
326355pub fn panicking ( ) -> bool {
You can’t perform that action at this time.
0 commit comments