| Crates.io | dropcatch |
| lib.rs | dropcatch |
| version | 0.3.0 |
| created_at | 2025-10-12 07:25:40.637526+00 |
| updated_at | 2025-10-12 09:43:32.515317+00 |
| description | Drop detection library for Rust. |
| homepage | https://github.com/metastable-void/dropcatch-rs |
| repository | https://github.com/metastable-void/dropcatch-rs |
| max_upload_size | |
| id | 1879020 |
| size | 36,598 |
With Clone, Sync, Send and optional PartialEq + Hash support.
use std::sync::{Arc, Mutex};
use dropcatch::DropCatcher;
// flag to track the dropped state
let flag = Arc::new(Mutex::new(false));
let flag_clone = flag.clone();
{
let dropped = DropCatcher::new(move || {
// called when DropCatcher is dropped
*flag_clone.lock().unwrap() = true;
});
let dropped_clone = dropped.clone();
assert_eq!(dropped, dropped_clone); // same instance
drop(dropped);
assert!(!*flag.lock().unwrap()); // not still dropped
}
assert!(*flag.lock().unwrap()); // dropped