#panic #thread #called

drop-panic

The callback that will be called if the current thread panics

1 unstable release

0.1.0 Mar 20, 2024

#32 in #called

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