Skip to main content

SendRefLiftFn

Trait SendRefLiftFn 

Source
pub trait SendRefLiftFn: SendCloneFn<Ref> {
    // Required method
    fn ref_new<'a, A: 'a, B: 'a>(
        f: impl 'a + Fn(&A) -> B + Send + Sync,
    ) -> <Self as SendCloneFn<Ref>>::Of<'a, A, B>;
}
Expand description

A trait for constructing thread-safe Ref-mode cloneable function wrappers.

This mirrors SendLiftFn but for by-reference closures (Fn(&A) -> B + Send + Sync).

Required Methods§

Source

fn ref_new<'a, A: 'a, B: 'a>( f: impl 'a + Fn(&A) -> B + Send + Sync, ) -> <Self as SendCloneFn<Ref>>::Of<'a, A, B>

Creates a new thread-safe cloneable by-reference function wrapper.

§Type Signature

forall A B. (&A -> B) -> Self A B

§Type Parameters
  • 'a: The lifetime of the function and its captured data.
  • A: The input type (the closure receives &A).
  • B: The output type of the function.
§Parameters
  • f: The by-reference closure to wrap. Must be Send + Sync.
§Returns

The wrapped thread-safe cloneable by-reference function.

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

let f = send_ref_lift_fn_new::<ArcFnBrand, _, _>(|x: &i32| *x * 2);
assert_eq!(f(&5), 10);

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§

Source§

impl<P: ToDynSendFn + ToDynCloneFn> SendRefLiftFn for FnBrand<P>

§Type Parameters
  • P: The reference-counted pointer type.