Skip to main content

SendDeferrable

Trait SendDeferrable 

Source
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§

Source

fn send_defer<F>(f: F) -> Self
where F: FnOnce() -> Self + Send + Sync + 'a, Self: Sized,

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);

Implementors§

Source§

impl<'a, A> SendDeferrable<'a> for Lazy<'a, A, ArcLazyConfig>
where A: Clone + Send + Sync + 'a,

Source§

impl<'a, A, E> SendDeferrable<'a> for TryLazy<'a, A, E, ArcLazyConfig>
where A: Clone + Send + Sync + 'a, E: Clone + Send + Sync + 'a,