# Trait ethcore_util::standard::ops::FnMut 1.0.0 [−] [src]

    pub trait FnMut<Args>: FnOnce<Args> {
        extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
    }

A version of the call operator that takes a mutable receiver.

# Examples

Closures that mutably capture variables automatically implement this trait, which allows them to be invoked.

    let mut x = 5;
    {
        let mut square_x = || x *= x;
        square_x();
    }
    assert_eq!(x, 25);

Closures can also be passed to higher-level functions through a `FnMut` parameter (or a `FnOnce` parameter, which is a supertrait of `FnMut`).

    fn do_twice<F>(mut func: F)
        where F: FnMut()
    {
        func();
        func();
    }

    let mut x: usize = 1;
    {
        let add_two_to_x = || x += 2;
        do_twice(add_two_to_x);
    }

    assert_eq!(x, 5);

## Required Methods

### `extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output`

Unstable (`fn_traits`)

This is called when the call operator is used.

## Implementors

- `impl<'a, A, F> FnMut<A> for &'a F where F: Fn<A> + ?Sized`
- `impl<'a, A, F> FnMut<A> for &'a mut F where F: FnMut<A> + ?Sized`

# 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
+
  Collapse/expand all sections

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