pub fn combine_all_option<T>(xs: &[T]) -> Option<T>where
    T: Semigroup + Clone,
Expand description

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

If the sequence is empty, returns None. Otherwise, returns Some(total).

Examples

use frunk::semigroup::combine_all_option;

let v1 = &vec![1, 2, 3];
assert_eq!(combine_all_option(v1), Some(6));

let v2: Vec<i16> = Vec::new(); // empty!
assert_eq!(combine_all_option(&v2), None);
Run