Skip to main content

defer

Function defer 

Source
pub fn defer<'a, D, F>(f: F) -> D
where 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 computation
  • D: 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);