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)
[src]

type Target = T

The resulting type after dereferencing

fn deref(&self) -> &T

The method called to dereference a value

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

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

The method called to mutably dereference a value

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

fn drop(&mut self)

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