Function frust::semigroup::combine_all_option [] [src]

pub fn combine_all_option<T>(xs: &Vec<T>) -> Option<T> where
    T: Semigroup + Clone

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

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


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);