Struct drop_guard::DropGuard [] [src]

pub struct DropGuard<T, F: FnMut(T)> { /* fields omitted */ }

Methods

impl<T: Sized, F: FnMut(T)> DropGuard<T, F>
[src]

Creates a new guard taking in your data and a function.

use drop_guard::DropGuard;
 
let s = String::from("a commonString");
let mut s = DropGuard::new(s, |final_string| println!("s became {} at last", final_string));
 
// much code and time passes by ...
*s = "a rainbow".to_string();
 
// by the end of this function the String will have become a rainbow

Trait Implementations

impl<T, F: FnMut(T)> Deref for DropGuard<T, F>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<T, F: FnMut(T)> DerefMut for DropGuard<T, F>
[src]

The method called to mutably dereference a value

impl<T, F: FnMut(T)> Drop for DropGuard<T, F>
[src]

A method called when the value goes out of scope. Read more