//does the monoid operation on the slice of tuples if the closure evaluates to true fn accumulate<'a, T: Monoid>(tuples: &[(&'a str, &Fn(i32) -> bool)], i: i32) -> Option where &'a str: Into { tuples.iter() .filter(|&&(_,include_fn)| include_fn(i)) .map(first) .fold(None, |acc, concat_str| acc.op(Some(concat_str.into()))) } fn first(&(ref one, _): &(A, B)) -> A { *one }