Trait thunk::LazyRef
[−]
[src]
pub trait LazyRef<'a>: Deref + AsRef<Self::Target> + From<Self::Target> + 'a where
Self::Target: Sized, { fn defer<F: FnOnce() -> Self::Target + 'a>(_: F) -> Self; fn force(&self); fn computed(t: Self::Target) -> Self { ... } }
The LazyRef
trait abstracts immutable references to lazily computed values.
Required Methods
fn defer<F: FnOnce() -> Self::Target + 'a>(_: 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.
Provided Methods
fn computed(t: Self::Target) -> Self
Construct a thunk with a precomputed value. This means unwrapping/dereferencing is effectively a no-op.
Implementors
impl<'a, T: 'a> LazyRef<'a> for Strict<T>
impl<'a, T: 'a> LazyRef<'a> for AtomicThunk<'a, T>
impl<'a, T: 'a> LazyRef<'a> for ArcThunk<'a, T>
impl<'a, T: 'a> LazyRef<'a> for Thunk<'a, T>
impl<'a, T: 'a> LazyRef<'a> for RcThunk<'a, T>