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§
Sourcefn ref_new<'a, A: 'a, B: 'a>(
f: impl 'a + Fn(&A) -> B + Send + Sync,
) -> <Self as SendCloneFn<Ref>>::Of<'a, A, B>
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 beSend + 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§
impl<P: ToDynSendFn + ToDynCloneFn> SendRefLiftFn for FnBrand<P>
§Type Parameters
P: The reference-counted pointer type.