Crate drop_guard [] [src]

This crate gives a generic way to add a callback to any dropping value

You may use this for debugging values, see the struct documentation or the standalone examples.


extern crate drop_guard;
use drop_guard::DropGuard;
use std::thread::{spawn, sleep};
use std::time::Duration;
fn main() {
    // The guard must have a name. `_` will drop it instantly, which would
    // lead to unexpected results
    let _g = DropGuard::new(spawn(move || {
                            println!("println! from thread");
                        , |join_handle| join_handle.join().unwrap());
    println!("Waiting for thread ...");



The DropGuard will remain to Send and Sync from T.