Skip to main content

Module foldable

Module foldable 

Source
Expand description

Data structures that can be folded into a single value from the left or right.

§Examples

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

let x = Some(5);
let y = fold_right::<RcFnBrand, OptionBrand, _, _, _>(|a, b| a + b, 10, x);
assert_eq!(y, 15);

Traits§

Foldable
A type class for structures that can be folded to a single value.

Functions§

fold_left
Folds the structure by applying a function from left to right.
fold_map
Maps values to a monoid and combines them.
fold_right
Folds the structure by applying a function from right to left.