#called #panics #thread

drop-panic

The callback that will be called if the current thread panics

1 unstable release

0.1.0 Mar 20, 2024

#9 in #called

Download history 134/week @ 2024-03-18 25/week @ 2024-04-01

159 downloads per month

MIT/Apache

3KB
59 lines

drop-panic

The callback that will be called if the current thread panics.

Example

let panicked = Arc::new(AtomicBool::new(false));

let jh = thread::spawn({
    let panicked = Arc::clone(&panicked);
    move || {
        drop_panic! {
            panicked.store(true, Ordering::Release);
        };

        panic!("boom");
    }
});

assert!(jh.join().is_err());
assert!(panicked.load(Ordering::Acquire));

No runtime deps