Skip to main content

Module send_ref_semiapplicative

Module send_ref_semiapplicative 

Source
Expand description

Thread-safe by-ref function application within contexts with send_ref_apply.

Like RefSemiapplicative::ref_apply, but uses SendCloneFn<Ref> for thread-safe function wrappers and requires element types to be Send + Sync.

§Examples

use fp_library::{
	brands::*,
	classes::*,
	functions::*,
	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 = send_ref_apply::<ArcFnBrand, LazyBrand<ArcLazyConfig>, _, _>(&f, &x);
assert_eq!(*result.evaluate(), 10);

Traits§

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

Functions§

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