Expand description
Dispatch for Foldable::fold_right,
fold_left,
fold_map, and their by-reference
counterparts in RefFoldable.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
// By-value fold_right (Vec)
let result = fold_right::<RcFnBrand, VecBrand, _, _, _, _>(|a, b| a + b, 0, vec![1, 2, 3]);
assert_eq!(result, 6);
// By-ref fold_right (Lazy, closure receives &A)
let lazy = RcLazy::new(|| 10);
let result =
fold_right::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(|a: &i32, b| *a + b, 5, &lazy);
assert_eq!(result, 15);Modules§
- explicit
- Explicit dispatch functions requiring a Brand turbofish.
Traits§
- Fold
Left Dispatch - Trait that routes a fold_left operation to the appropriate type class method.
- Fold
MapDispatch - Trait that routes a fold_map operation to the appropriate type class method.
- Fold
Right Dispatch - Trait that routes a fold_right operation to the appropriate type class method.
Functions§
- fold_
left - Folds a structure from the left, inferring the brand from the container type.
- fold_
map - Maps values to a monoid and combines them, inferring the brand from the container type.
- fold_
right - Folds a structure from the right, inferring the brand from the container type.