https://github.com/bells307/drop-panic
The callback that will be called if the current thread panics
https://github.com/bells307/drop-panic
panic rust
Last synced: 6 months ago
JSON representation
The callback that will be called if the current thread panics
- Host: GitHub
- URL: https://github.com/bells307/drop-panic
- Owner: bells307
- Created: 2024-03-18T19:30:39.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T06:33:45.000Z (almost 2 years ago)
- Last Synced: 2025-06-11T13:58:49.102Z (7 months ago)
- Topics: panic, rust
- Language: Rust
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# drop-panic
The callback that will be called if the current thread panics.
## Example
```rust
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));
```