Struct immutable_seq::lazy::Thunk
[−]
[src]
pub struct Thunk<T>(_);
A lazily evaluated value.
Methods
impl<T> Thunk<T>
[src]
fn new<F>(producer: F) -> Thunk<T> where F: FnOnce() -> ThunkResult<T> + 'static
Create a lazily evaluated value from a proc that returns that value.
You can construct Thunk's manually using this, but the lazy! macro is preferred.
let expensive = Thunk::new(|| { println!("Evaluated!"); value(7u32) }); assert_eq!(*expensive, 7u32); // "Evaluated!" gets printed here. assert_eq!(*expensive, 7u32); // Nothing printed.
fn evaluated(val: T) -> Thunk<T>
Create a new, evaluated, thunk from a value.
fn force(&self)
Force evaluation of a thunk.
Trait Implementations
impl<T> Deref for Thunk<T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T> Clone for Thunk<T>
[src]
fn clone(&self) -> Thunk<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more