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

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.

Manually force a thunk's computation.

Provided Methods

Construct a thunk with a precomputed value. This means forcing the thunk is a no-op.

Implementors