Struct namable_closures::closures::ClosureMut [−][src]
pub struct ClosureMut<'a, State, Input, Output> where
State: 'a, { /* fields omitted */ }
A namable closure that does not own its state and can mutate it when called.
It is not possible to implement Copy
or Clone
for this type.
Correspond to unnamable closures like:
ⓘThis example is not tested
|...| { /* mutates captured variables */ }
Example:
let mut state = 0; { let mut match_cnt:ClosureMut<i32,(i32,i32),()> = closure!(mut state=&mut state => |a,b| {if a==b { *state+=1 }}); for i in 0..10 { match_cnt.stable_call_mut((i,i*3%10)); } } assert_eq!(state,2);
Methods
impl<'a, State, Input, Output> ClosureMut<'a, State, Input, Output>
[src]
impl<'a, State, Input, Output> ClosureMut<'a, State, Input, Output>
pub fn new(f: fn(_: &mut State, _: Input) -> Output, t: &'a mut State) -> Self
[src]
pub fn new(f: fn(_: &mut State, _: Input) -> Output, t: &'a mut State) -> Self
pub fn call_with_state(&self, s: &mut State, i: Input) -> Output
[src]
pub fn call_with_state(&self, s: &mut State, i: Input) -> Output
Trait Implementations
impl<'a, State, Input, Output> StableFnOnce<Input> for ClosureMut<'a, State, Input, Output>
[src]
impl<'a, State, Input, Output> StableFnOnce<Input> for ClosureMut<'a, State, Input, Output>
type Output = Output
fn stable_call_once(self, i: Input) -> Output
[src]
fn stable_call_once(self, i: Input) -> Output
impl<'a, State, Input, Output> StableFnMut<Input> for ClosureMut<'a, State, Input, Output>
[src]
impl<'a, State, Input, Output> StableFnMut<Input> for ClosureMut<'a, State, Input, Output>
fn stable_call_mut(&mut self, i: Input) -> Output
[src]
fn stable_call_mut(&mut self, i: Input) -> Output
Auto Trait Implementations
impl<'a, State, Input, Output> Send for ClosureMut<'a, State, Input, Output> where
State: Send,
impl<'a, State, Input, Output> Send for ClosureMut<'a, State, Input, Output> where
State: Send,
impl<'a, State, Input, Output> Sync for ClosureMut<'a, State, Input, Output> where
State: Sync,
impl<'a, State, Input, Output> Sync for ClosureMut<'a, State, Input, Output> where
State: Sync,