pub fn defer<'a, D, F>(f: F) -> Dwhere
D: Deferrable<'a>,
F: FnOnce() -> D + 'a,Expand description
Creates a value from a computation that produces the value.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall d. Deferrable d => (() -> d) -> d
§Type Parameters
'a: The lifetime of the computationD: The type of the deferred value.F: The type of the thunk.
§Parameters
f: A thunk that produces the value.
§Returns
The deferred value.
§Examples
use fp_library::{brands::*, functions::*, types::*};
let eval: Thunk<i32> = defer(|| Thunk::new(|| 42));
assert_eq!(eval.evaluate(), 42);