pub fn fold_map<'a, FnBrand, FA, A: 'a, M: Monoid + 'a, Marker>(
func: impl FoldMapDispatch<'a, FnBrand, <FA as InferableBrand_cdc7cd43dac7585f>::Brand, A, M, FA, Marker>,
fa: FA,
) -> Mwhere
FA: InferableBrand_cdc7cd43dac7585f,Expand description
Maps values to a monoid and combines them, inferring the brand from the container type.
The Brand type parameter is inferred from the concrete type of fa
via InferableBrand. FnBrand must still be specified explicitly.
Both owned and borrowed containers are supported.
For types with multiple brands, use
explicit::fold_map with a turbofish.
§Type Signature
forall Brand A M. (Foldable Brand, Monoid M) => (A -> M, Brand A) -> M
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function to use (must be specified explicitly).FA: The container type (owned or borrowed). Brand is inferred from this.A: The type of the elements.M: The monoid type.Marker: Dispatch marker type, inferred automatically.
§Parameters
func: The mapping function.fa: The structure to fold (owned for Val, borrowed for Ref).
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
functions::*,
};
let result = fold_map::<RcFnBrand, _, _, _, _>(|a: i32| a.to_string(), vec![1, 2, 3]);
assert_eq!(result, "123");