pub trait SendDeferrable<'a> {
// Required method
fn send_defer(f: impl FnOnce() -> Self + Send + Sync + 'a) -> Self
where 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.
§Type Parameters
'a: The lifetime of the computation.
Required Methods§
Sourcefn send_defer(f: impl FnOnce() -> Self + Send + Sync + 'a) -> Selfwhere
Self: Sized,
fn send_defer(f: impl FnOnce() -> Self + Send + Sync + 'a) -> Selfwhere
Self: Sized,
Creates a deferred value from a thread-safe thunk.
§Type Signature
(() -> Self) -> Self
§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);Implementors§
impl<'a, A> SendDeferrable<'a> for Lazy<'a, A, ArcLazyConfig>
§Type Parameters
'a: The lifetime of the reference.A: The type of the computed value.
impl<'a, A, E> SendDeferrable<'a> for TryLazy<'a, A, E, ArcLazyConfig>
§Type Parameters
'a: The lifetime of the computation.A: The type of the computed value.E: The type of the error.