Skip to main content

Thunk

Trait Thunk 

Source
pub trait Thunk: Send + Sync {
    // Required method
    fn force(&self, cx: &mut Cx, demand: Demand) -> Result<Value>;
}
Expand description

A delayed computation that produces a value when forced.

Thunks are how lazy and call-by-need eval policies defer argument evaluation: the value is computed only when force is called to satisfy a Demand. The kernel defines the contract and two reference objects (LazyThunkObject and ThunkObject); libraries may supply their own.

Required Methods§

Source

fn force(&self, cx: &mut Cx, demand: Demand) -> Result<Value>

Forces the delayed computation, returning its value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§