Struct namable_closures::closures::ClosureRef [−][src]
pub struct ClosureRef<State, Input, Output> { /* fields omitted */ }
A Closure does not own its state, and only refers to the state when called.
Correspond to unnamable closures like:
ⓘThis example is not tested
|...| { /* only refers captured variables */ }
Examples:
// state refered as reference in body, but moved to the closure let add_ten:ClosureRef<i32,(i32,),i32> = closure!(ref state=10 => move |i| i+*state); assert_eq!(add_ten.stable_call((1,)),11); let mut offset:ClosureRef<Point,(i32,i32),Point> = closure!(ref state=Point::new(10,20) => move |a,b| Point::new(state.x+a,state.y+b)); let p = offset.stable_call_mut((1,2)); assert_eq!(p.x,11); assert_eq!(p.y,22);
Methods
impl<State, Input, Output> ClosureRef<State, Input, Output>
[src]
impl<State, Input, Output> ClosureRef<State, Input, Output>
pub fn new(f: fn(_: &State, _: Input) -> Output, t: State) -> Self
[src]
pub fn new(f: fn(_: &State, _: Input) -> Output, t: State) -> Self
pub fn call_with_state(&self, s: &State, i: Input) -> Output
[src]
pub fn call_with_state(&self, s: &State, i: Input) -> Output
Trait Implementations
impl<State, Input, Output> Copy for ClosureRef<State, Input, Output> where
State: Copy,
[src]
impl<State, Input, Output> Copy for ClosureRef<State, Input, Output> where
State: Copy,
impl<State, Input, Output> Clone for ClosureRef<State, Input, Output> where
State: Clone,
[src]
impl<State, Input, Output> Clone for ClosureRef<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 ClosureRef<State, Input, Output>
[src]
impl<State, Input, Output> StableFnOnce<Input> for ClosureRef<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 ClosureRef<State, Input, Output>
[src]
impl<State, Input, Output> StableFnMut<Input> for ClosureRef<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 ClosureRef<State, Input, Output>
[src]
impl<State, Input, Output> StableFn<Input> for ClosureRef<State, Input, Output>
fn stable_call(&self, i: Input) -> Output
[src]
fn stable_call(&self, i: Input) -> Output
Auto Trait Implementations
impl<State, Input, Output> Send for ClosureRef<State, Input, Output> where
State: Send,
impl<State, Input, Output> Send for ClosureRef<State, Input, Output> where
State: Send,
impl<State, Input, Output> Sync for ClosureRef<State, Input, Output> where
State: Sync,
impl<State, Input, Output> Sync for ClosureRef<State, Input, Output> where
State: Sync,