run-on-drop

Crates.iorun-on-drop
lib.rsrun-on-drop
version1.0.0
created_at2025-04-15 13:21:57.944103+00
updated_at2025-04-15 13:21:57.944103+00
descriptionRun code when an object is dropped
homepage
repositoryhttps://github.com/mahkoh/run-on-drop
max_upload_size
id1634416
size7,413
(mahkoh)

documentation

README

run-on-drop

crates.io docs.rs MSRV

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.

Commit count: 1

cargo fmt