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]
impl<State, Input, Output> ClosureOnce<State, Input, Output>
pub fn new(
f: fn(_: State, _: Input) -> Output,
t: State
) -> ClosureOnce<State, Input, Output>
[src]
pub fn new(
f: fn(_: State, _: Input) -> Output,
t: State
) -> ClosureOnce<State, Input, Output>
Trait Implementations
impl<State, Input, Output> Copy for ClosureOnce<State, Input, Output> where
State: Copy,
[src]
impl<State, Input, Output> Copy for ClosureOnce<State, Input, Output> where
State: Copy,
impl<State, Input, Output> Clone for ClosureOnce<State, Input, Output> where
State: Clone,
[src]
impl<State, Input, Output> Clone for ClosureOnce<State, Input, Output> where
State: Clone,
fn clone(&self) -> ClosureOnce<State, Input, Output>
[src]
fn clone(&self) -> ClosureOnce<State, Input, Output>
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 ClosureOnce<State, Input, Output>
[src]
impl<State, Input, Output> StableFnOnce<Input> for ClosureOnce<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 ClosureOnce<State, Input, Output> where
State: Copy,
[src]
impl<State, Input, Output> StableFnMut<Input> for ClosureOnce<State, Input, Output> where
State: Copy,
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 ClosureOnce<State, Input, Output> where
State: Copy,
[src]
impl<State, Input, Output> StableFn<Input> for ClosureOnce<State, Input, Output> where
State: Copy,
fn stable_call(&self, i: Input) -> Output
[src]
fn stable_call(&self, i: Input) -> Output
Auto Trait Implementations
impl<State, Input, Output> Send for ClosureOnce<State, Input, Output> where
State: Send,
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,
impl<State, Input, Output> Sync for ClosureOnce<State, Input, Output> where
State: Sync,