pub fn send_ref_fold_map<'a, FnBrand: SendLiftFn + 'a, Brand: SendRefFoldable, A: Send + Sync + 'a + Clone, M>(
func: impl Fn(&A) -> M + Send + Sync + 'a,
fa: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> MExpand description
Maps values to a monoid by reference and combines them (thread-safe).
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall Brand A M. (SendRefFoldable Brand, Monoid M) => (&A -> M, &Brand A) -> M
§Type Parameters
'a: The lifetime of the elements.FnBrand: The brand of the cloneable function to use.Brand: The brand of the structure.A: The type of the elements.M: The monoid type.
§Parameters
func: The function to map each element reference to a monoid.fa: The structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
classes::send_ref_foldable::*,
types::*,
};
let lazy = ArcLazy::new(|| 5);
let result = send_ref_fold_map::<ArcFnBrand, LazyBrand<ArcLazyConfig>, _, _>(
|a: &i32| a.to_string(),
&lazy,
);
assert_eq!(result, "5");