Skip to main content

SendDefer

Trait SendDefer 

Source
pub trait SendDefer: Kind_cdc7cd43dac7585f {
    // Required method
    fn send_defer<'a, A>(
        thunk: impl 'a + Fn() -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A> + Send + Sync,
    ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
       where A: Clone + Send + Sync + 'a;
}
Expand description

A trait for deferred lazy evaluation with thread-safe thunks.

This is similar to Defer, but the thunk must be Send + Sync.

Required Methods§

Source

fn send_defer<'a, A>( thunk: impl 'a + Fn() -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A> + Send + Sync, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
where A: Clone + Send + Sync + 'a,

Creates a deferred value from a thread-safe thunk.

§Type Signature

forall f a. (SendDefer f, Send a, Sync a) => (() -> a) -> f a

§Type Parameters
  • A: The type of the value.
§Parameters
  • thunk: The function that produces the value.
§Returns

A deferred value.

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§