Struct scopeguard::Guard [] [src]

pub struct Guard<T, F> where F: FnMut(&mut T) {
    // some fields omitted
}

Guard is a scope guard that may own a protected value.

If you place a guard value in a local variable, its destructor will run regardless how you leave the function — regular return or panic (barring abnormal incidents like aborts; so as long as destructors run).

The guard's closure will be called with a mut ref to the held value in the destructor. It's called only once.

The Guard implements Deref so that you can access the inner value.

Trait Implementations

impl<T, F> Deref for Guard<T, F> where F: FnMut(&mut T)

type Target = T

fn deref(&self) -> &T

impl<T, F> DerefMut for Guard<T, F> where F: FnMut(&mut T)

fn deref_mut(&mut self) -> &mut T

impl<T, F> Drop for Guard<T, F> where F: FnMut(&mut T)

fn drop(&mut self)