pub struct ClosureRef<State, Input, Output> { /* private fields */ }Expand description
A Closure does not own its state, and only refers to the state when called.
Correspond to unnamable closures like:
ⓘ
|...| { /* 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);Implementations§
Source§impl<State, Input, Output> ClosureRef<State, Input, Output>
impl<State, Input, Output> ClosureRef<State, Input, Output>
Trait Implementations§
Source§impl<State, Input, Output> Clone for ClosureRef<State, Input, Output>where
State: Clone,
impl<State, Input, Output> Clone for ClosureRef<State, Input, Output>where
State: Clone,
Source§impl<State, Input, Output> StableFn<Input> for ClosureRef<State, Input, Output>
impl<State, Input, Output> StableFn<Input> for ClosureRef<State, Input, Output>
fn stable_call(&self, i: Input) -> Output
Source§impl<State, Input, Output> StableFnMut<Input> for ClosureRef<State, Input, Output>
impl<State, Input, Output> StableFnMut<Input> for ClosureRef<State, Input, Output>
fn stable_call_mut(&mut self, i: Input) -> Output
Source§impl<State, Input, Output> StableFnOnce<Input> for ClosureRef<State, Input, Output>
impl<State, Input, Output> StableFnOnce<Input> for ClosureRef<State, Input, Output>
impl<State, Input, Output> Copy for ClosureRef<State, Input, Output>where
State: Copy,
Auto Trait Implementations§
impl<State, Input, Output> Freeze for ClosureRef<State, Input, Output>where
State: Freeze,
impl<State, Input, Output> RefUnwindSafe for ClosureRef<State, Input, Output>where
State: RefUnwindSafe,
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> Unpin for ClosureRef<State, Input, Output>where
State: Unpin,
impl<State, Input, Output> UnwindSafe for ClosureRef<State, Input, Output>where
State: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more