pub trait AdditiveIterator<A> { fn sum(&mut self) -> A; }
A trait for iterators over elements which can be added together
fn sum(&mut self) -> A
Iterates over the entire iterator, summing up all the elements
let a = [1, 2, 3, 4, 5];
let mut it = a.iter().map(|&x| x);
assert!(it.sum() == 15);
impl<A: Add<A, A> + Zero, T: Iterator<A>> AdditiveIterator<A> for T
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).