Function std::thread::panicking1.0.0 [] [src]

pub fn panicking() -> bool

Determines whether the current thread is unwinding because of panic.

Examples

use std::thread;

struct SomeStruct;

impl Drop for SomeStruct {
    fn drop(&mut self) {
        if thread::panicking() {
            println!("dropped while unwinding");
        } else {
            println!("dropped while not unwinding");
        }
    }
}

{
    print!("a: ");
    let a = SomeStruct;
}

{
    print!("b: ");
    let b = SomeStruct;
    panic!()
}Run