Skip to main content

SendDeferrable

Trait SendDeferrable 

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

Source

fn send_defer(f: impl FnOnce() -> Self + Send + Sync + 'a) -> Self
where 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§

Source§

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

§Type Parameters
  • 'a: The lifetime of the reference.
  • A: The type of the computed value.
Source§

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

§Type Parameters
  • 'a: The lifetime of the computation.
  • A: The type of the computed value.
  • E: The type of the error.