Skip to main content

SendRefSemiapplicative

Trait SendRefSemiapplicative 

Source
pub trait SendRefSemiapplicative:
    SendRefLift
    + SendRefFunctor
    + Kind_cdc7cd43dac7585f {
    // Required method
    fn send_ref_apply<'a, FnBrand: 'a + SendCloneFn<Ref>, A: Send + Sync + 'a, B: Send + Sync + 'a>(
        ff: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as SendCloneFn<Ref>>::Of<'a, A, B>>,
        fa: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
    ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>;
}
Expand description

A type class for applying wrapped thread-safe by-ref functions within contexts.

The wrapped functions have type Fn(&A) -> B + Send + Sync (via SendCloneFn<Ref>). No Clone bound on A is needed; the function receives a reference and produces an owned result.

This is the thread-safe counterpart of RefSemiapplicative.

Required Methods§

Source

fn send_ref_apply<'a, FnBrand: 'a + SendCloneFn<Ref>, A: Send + Sync + 'a, B: Send + Sync + 'a>( ff: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as SendCloneFn<Ref>>::Of<'a, A, B>>, fa: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>

Applies a wrapped thread-safe by-ref function to a value within a context.

§Type Signature

forall A B. SendCloneFn FnBrand => (&Self (FnBrand A B), &Self A) -> Self B

§Type Parameters
  • 'a: The lifetime of the values.
  • FnBrand: The brand of the thread-safe cloneable function wrapper.
  • A: The type of the input value.
  • B: The type of the output value.
§Parameters
  • ff: The context containing the wrapped thread-safe by-ref function.
  • fa: The context containing the value.
§Returns

A new context containing the result of applying the function.

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

let f = ArcLazy::new(|| {
	std::sync::Arc::new(|x: &i32| *x * 2) as std::sync::Arc<dyn Fn(&i32) -> i32 + Send + Sync>
});
let x = ArcLazy::new(|| 5);
let result = LazyBrand::<ArcLazyConfig>::send_ref_apply::<ArcFnBrand, _, _>(&f, &x);
assert_eq!(*result.evaluate(), 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§