# 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)`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)