1 stable release
| 1.0.0 | Apr 15, 2025 |
|---|
#1088 in Rust patterns
649 downloads per month
Used in 3 crates
(2 directly)
6KB
95 lines
This crate provides a closure wrapper that will run the closure when it is dropped.
See on_drop for examples.
run-on-drop
This crate provides a closure wrapper that will run the closure when it is dropped.
Example
use run_on_drop::on_drop;
let object = create_object();
let cleanup = on_drop(|| destroy_object(&object));
initialize_object(&object); // might unwind
cleanup.forget();
return object;
MSRV
The MSRV is max(stable - 3).
License
This project is licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.