https://github.com/metastable-void/dropcatch-rs
Drop detection library for Rust
https://github.com/metastable-void/dropcatch-rs
rust rust-lifetime
Last synced: 3 months ago
JSON representation
Drop detection library for Rust
- Host: GitHub
- URL: https://github.com/metastable-void/dropcatch-rs
- Owner: metastable-void
- License: apache-2.0
- Created: 2025-10-12T07:25:02.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-10-12T09:43:24.000Z (9 months ago)
- Last Synced: 2025-11-18T12:09:20.108Z (8 months ago)
- Topics: rust, rust-lifetime
- Language: Rust
- Homepage: https://crates.io/crates/dropcatch
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.APACHE
Awesome Lists containing this project
README
# Drop detection library for Rust
With Clone, Sync, Send and optional PartialEq + Hash support.
## Examples
```rust
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
```