pub trait SendDeferrable<'a> {
// Required method
fn send_defer<F>(f: F) -> Self
where F: FnOnce() -> Self + Send + Sync + 'a,
Self: Sized;
}Expand description
A trait for deferred lazy evaluation with thread-safe thunks.
This is similar to Deferrable, but the thunk must be Send + Sync.
Required Methods§
Sourcefn send_defer<F>(f: F) -> Self
fn send_defer<F>(f: F) -> Self
Creates a deferred value from a thread-safe thunk.
§Type Signature
forall self. SendDeferrable self => (() -> self) -> self
§Type Parameters
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);