Trait thunk::Lazy
[−]
[src]
pub trait Lazy where
Self: AsRef<Self::Target> + AsMut<Self::Target>,
Self: Deref + DerefMut + From<Self::Target>,
Self::Target: Sized, { fn defer<F: FnOnce() -> Self::Target + 'static>(_: F) -> Self; fn force(&self); fn unwrap(self) -> Self::Target; fn computed(t: Self::Target) -> Self { ... } }
The Lazy
trait abstracts lazily computed values, also known as "thunks".
Required Methods
fn defer<F: FnOnce() -> Self::Target + 'static>(_: F) -> Self
Defer a computation stored as a FnOnce
closure. Unwrapping/dereferencing
will force the computation of the closure.
fn force(&self)
Manually force a thunk's computation.
fn unwrap(self) -> Self::Target
Unwrap a thunk into its inner value. This forces the thunk.
Provided Methods
fn computed(t: Self::Target) -> Self
Construct a thunk with a precomputed value. This means unwrapping/dereferencing is effectively a no-op.