Skip to main content

Module send_ref_semimonad

Module send_ref_semimonad 

Source
Expand description

Thread-safe by-ref monadic sequencing with send_ref_bind.

Like RefSemimonad::ref_bind, but the continuation must be Send and element types must be Send + Sync.

§Examples

use fp_library::{
	brands::*,
	classes::*,
	functions::*,
	types::*,
};

let lazy = ArcLazy::new(|| 5);
let result = send_ref_bind::<LazyBrand<ArcLazyConfig>, _, _>(&lazy, |x: &i32| {
	let v = *x * 2;
	ArcLazy::new(move || v)
});
assert_eq!(*result.evaluate(), 10);

Traits§

SendRefSemimonad
A type class for thread-safe monadic sequencing via references.

Functions§

send_ref_bind
Sequences a thread-safe computation using a reference to the value.