Function frunk::monoid::combine_all

source ·
pub fn combine_all<T>(xs: &[T]) -> T
where T: Monoid + Semigroup + Clone,
Expand description

Given a sequence of xs, combine them and return the total

Examples

use frunk::monoid::combine_all;

assert_eq!(combine_all(&vec![Some(1), Some(3)]), Some(4));

let empty_vec_opt_int: Vec<Option<i32>> = Vec::new();
assert_eq!(combine_all(&empty_vec_opt_int), None);

let vec_of_some_strings = vec![Some(String::from("Hello")), Some(String::from(" World"))];
assert_eq!(combine_all(&vec_of_some_strings), Some(String::from("Hello World")));
Run