Struct namable_closures::closures::Closure[][src]

pub struct Closure<'a, State, Input, Output> where
    State: 'a, 
{ /* fields omitted */ }

A Closure owns its state, and only refers to the state when called.

Correspond to unnamable closures like:

This example is not tested
|...| { /* only refers captured variables */ }

Example:

let state = 10;
let add_ten:Closure<i32,(i32,),i32>
    = closure!(state=&state => |i| i+10);
assert_eq!(add_ten.stable_call((1,)),11);
let state = Point::new(10,20);
let mut offset:Closure<Point,(i32,i32),Point>
    = closure!(state=&state => |a,b| Point::new(state.x+a,state.y+b));
let p = offset.stable_call_mut((1i32,2i32));
assert_eq!(p.x,11);
assert_eq!(p.y,22);

Methods

impl<'a, State, Input, Output> Closure<'a, State, Input, Output>
[src]

Trait Implementations

impl<'a, State, Input, Output> Copy for Closure<'a, State, Input, Output>
[src]

impl<'a, State, Input, Output> Clone for Closure<'a, State, Input, Output>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, State, Input, Output> StableFnOnce<Input> for Closure<'a, State, Input, Output>
[src]

impl<'a, State, Input, Output> StableFnMut<Input> for Closure<'a, State, Input, Output>
[src]

impl<'a, State, Input, Output> StableFn<Input> for Closure<'a, State, Input, Output>
[src]

Auto Trait Implementations

impl<'a, State, Input, Output> Send for Closure<'a, State, Input, Output> where
    State: Sync

impl<'a, State, Input, Output> Sync for Closure<'a, State, Input, Output> where
    State: Sync