Skip to main content

Module send_cloneable_fn

Module send_cloneable_fn 

Source
Expand description

Thread-safe cloneable wrappers over closures that carry Send + Sync bounds.

§Examples

use fp_library::{functions::*, brands::*};
use std::thread;

let f = send_cloneable_fn_new::<ArcFnBrand, _, _>(|x: i32| x * 2);

// Can be sent to another thread
let handle = thread::spawn(move || {
    assert_eq!(f(5), 10);
});
handle.join().unwrap();

Traits§

SendCloneableFn
Abstraction for thread-safe cloneable wrappers over closures.

Functions§

new
Creates a new thread-safe cloneable function wrapper.