Struct namable_closures::closures::ClosureOnce[][src]

pub struct ClosureOnce<State, Input, Output> { /* fields omitted */ }

When called, it consumes its state. So it can only be called once.

Correspond to unnamable closures like:

This example is not tested
move |...| { /*consumes captured variables */ }

Example:

let sign_on:ClosureOnce<Passwd,(String,),Result<(),io::Error>>
    = closure!(passwd=Passwd::get_from_cache() => move |user| authenticate(user,passwd));
let auth:ClosureOnce<RoleSet,(String,Passwd),Result<(),io::Error>>
    = closure!(role_set=RoleSet::from_config() => move |user,passwd| check_user(role_set,user,passwd));
let send_data:ClosureOnce<MyStream,(&[u8],),Result<usize,io::Error>>
    = closure!(mut stream=MyStream::new() => move |data| stream.write_all(data));
send_data.stable_call_once((&[1u8],));
let read_data:ClosureOnce<MyStream,(&mut [u8],usize),Result<(),io::Error>>
    = closure!(mut stream=MyStream::new() => move |buf,len| stream.read_exact_ex(buf, len));

Methods

impl<State, Input, Output> ClosureOnce<State, Input, Output>
[src]

Trait Implementations

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

impl<State, Input, Output> Clone for ClosureOnce<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 ClosureOnce<State, Input, Output>
[src]

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

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

Auto Trait Implementations

impl<State, Input, Output> Send for ClosureOnce<State, Input, Output> where
    State: Send

impl<State, Input, Output> Sync for ClosureOnce<State, Input, Output> where
    State: Sync