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]

Trait Implementations

impl<State, Input, Output> Copy for ClosureRef<State, Input, Output> where
    State: Copy
[src]

impl<State, Input, Output> Clone for ClosureRef<State, Input, Output> where
    State: Clone
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<State, Input, Output> StableFnOnce<Input> for ClosureRef<State, Input, Output>
[src]

impl<State, Input, Output> StableFnMut<Input> for ClosureRef<State, Input, Output>
[src]

impl<State, Input, Output> StableFn<Input> for ClosureRef<State, Input, Output>
[src]

Auto Trait Implementations

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