Struct namable_closures::closures::ClosureRefMut [−][src]
pub struct ClosureRefMut<State, Input, Output> { /* fields omitted */ }
A namable closure that owns its state and can mutate it when called.
Correspond to unnamable closures like:
ⓘThis example is not tested
move |...| { /* mutates captured variables */ }
Example:
let mut accumulate:ClosureRefMut<i32,(i32,),i32> = closure!(ref mut state=0 => move |c| {*state+=c;*state}); assert_eq!(accumulate.stable_call_mut((1,)),1); assert_eq!(accumulate.stable_call_once((2,)),3);
Methods
impl<State, Input, Output> ClosureRefMut<State, Input, Output>
[src]
impl<State, Input, Output> ClosureRefMut<State, Input, Output>
Trait Implementations
impl<State, Input, Output> Copy for ClosureRefMut<State, Input, Output> where
State: Copy,
[src]
impl<State, Input, Output> Copy for ClosureRefMut<State, Input, Output> where
State: Copy,
impl<State, Input, Output> Clone for ClosureRefMut<State, Input, Output> where
State: Clone,
[src]
impl<State, Input, Output> Clone for ClosureRefMut<State, Input, Output> where
State: Clone,
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0
[src]Performs copy-assignment from source
. Read more
impl<State, Input, Output> StableFnOnce<Input> for ClosureRefMut<State, Input, Output>
[src]
impl<State, Input, Output> StableFnOnce<Input> for ClosureRefMut<State, Input, Output>
type Output = Output
fn stable_call_once(self, i: Input) -> Output
[src]
fn stable_call_once(self, i: Input) -> Output
impl<State, Input, Output> StableFnMut<Input> for ClosureRefMut<State, Input, Output>
[src]
impl<State, Input, Output> StableFnMut<Input> for ClosureRefMut<State, Input, Output>
fn stable_call_mut(&mut self, i: Input) -> Output
[src]
fn stable_call_mut(&mut self, i: Input) -> Output
impl<State, Input, Output> StableFn<Input> for ClosureRefMut<State, Input, Output> where
State: Copy,
[src]
impl<State, Input, Output> StableFn<Input> for ClosureRefMut<State, Input, Output> where
State: Copy,
Note we implemented StableFn
but not Fn
for ClosureRefMut
.
The reason is that if we implement Fn
in this way it will be chosen to use
when called, but its behavour is different than call_mut
as it does not
actually mutate the state - only a copy of the state was mutated.
This argument does not apply to StableFn
, as it is up to the user to decide
whether stable_call
(do not mutate) or stable_call_mut
(do mutate) should
be called.
fn stable_call(&self, i: Input) -> Output
[src]
fn stable_call(&self, i: Input) -> Output
Auto Trait Implementations
impl<State, Input, Output> Send for ClosureRefMut<State, Input, Output> where
State: Send,
impl<State, Input, Output> Send for ClosureRefMut<State, Input, Output> where
State: Send,
impl<State, Input, Output> Sync for ClosureRefMut<State, Input, Output> where
State: Sync,
impl<State, Input, Output> Sync for ClosureRefMut<State, Input, Output> where
State: Sync,