Skip to main content

Module par_ref_functor

Module par_ref_functor 

Source
Expand description

Parallel by-reference functor mapping.

User story: “I want to map over a collection by reference in parallel.”

This trait combines the by-reference access of RefFunctor with the parallelism of ParFunctor. The closure receives &A (no consumption of elements) and must be Send + Sync. Elements must be Send + Sync for rayon’s par_iter().

§Examples

use fp_library::{
	brands::VecBrand,
	classes::par_ref_functor::ParRefFunctor,
};

let v = vec![1, 2, 3];
let result = VecBrand::par_ref_map(|x: &i32| x.to_string(), &v);
assert_eq!(result, vec!["1", "2", "3"]);

Traits§

ParRefFunctor
Parallel by-reference functor mapping.

Functions§

par_ref_map
Maps a function over a structure by reference in parallel.