pub struct Thunk<E, V>(/* private fields */);
Expand description
A lazily evaluated value.
Implementations§
source§impl<E, V> Thunk<E, V>where
E: Evaluate<V>,
impl<E, V> Thunk<E, V>where
E: Evaluate<V>,
sourcepub fn new(e: E) -> Thunk<E, V>
pub fn new(e: E) -> Thunk<E, V>
Create a lazily evaluated value from
a value implementing the Evaluate
trait.
The lazy!
macro is preferred if you want to
construct values from closures.
let expensive = Thunk::new(|| { println!("Evaluated!"); 7 });
assert_eq!(*expensive, 7); // "Evaluated!" gets printed here.
assert_eq!(*expensive, 7); // Nothing printed.
Trait Implementations§
Auto Trait Implementations§
impl<E, V> !Freeze for Thunk<E, V>
impl<E, V> !RefUnwindSafe for Thunk<E, V>
impl<E, V> Send for Thunk<E, V>
impl<E, V> !Sync for Thunk<E, V>
impl<E, V> Unpin for Thunk<E, V>
impl<E, V> UnwindSafe for Thunk<E, V>where
E: UnwindSafe,
V: 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