Trait thunk::LazyRef
[−]
[src]
pub trait LazyRef: Deref + Sized where
Self::Target: Into<Self> + Sized, { fn defer<'a, F: FnOnce() -> Self::Target + 'a>(_: F) -> Self
where
Self::Target: 'a; fn force(&self); fn computed(t: Self::Target) -> Self { ... } }
The Lazy
trait abstracts thunks which have exactly the same lifetimes
as the types they defer computation of.
Required Methods
fn defer<'a, F: FnOnce() -> Self::Target + 'a>(_: F) -> Self where
Self::Target: 'a,
Self::Target: 'a,
Defer a computation stored as a FnOnce
closure. Unwrapping/dereferencing
will force the computation of the closure. The supplied closure must live
as long as the type which the thunk computes.
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 forcing the thunk is a no-op.
Implementors
impl<T> LazyRef for Strict<T>
impl<T> LazyRef for AtomicThunk<T>
impl<T> LazyRef for ArcThunk<T>
impl<T> LazyRef for Thunk<T>
impl<T> LazyRef for RcThunk<T>