Skip to main content

send_defer

Function send_defer 

Source
pub fn send_defer<'a, D, F>(f: F) -> D
where D: SendDeferrable<'a>, F: FnOnce() -> D + Send + Sync + 'a,
Expand description

Creates a deferred value from a thread-safe thunk.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall d. SendDeferrable 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: The function that produces the value.

§Returns

A deferred value.

§Examples

use fp_library::{brands::*, functions::*, types::*};

let memo: ArcLazy<i32> = send_defer(|| ArcLazy::new(|| 42));
assert_eq!(*memo.evaluate(), 42);