Crates.io | run-on-drop |
lib.rs | run-on-drop |
version | 1.0.0 |
created_at | 2025-04-15 13:21:57.944103+00 |
updated_at | 2025-04-15 13:21:57.944103+00 |
description | Run code when an object is dropped |
homepage | |
repository | https://github.com/mahkoh/run-on-drop |
max_upload_size | |
id | 1634416 |
size | 7,413 |
This crate provides a closure wrapper that will run the closure when it is dropped.
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;
The MSRV is max(stable - 3)
.
This project is licensed under either of
at your option.