pub trait Sum<A = Self>: Sized {
fn sum<I: Iterator<Item = A>>(iter: I) -> Self;
}
Expand description
Trait to represent types that can be created by summing up an iterator.
This trait is used to implement Iterator::sum()
. Types which implement
this trait can be generated by using the sum()
method on an iterator.
Like FromIterator
, this trait should rarely be called directly.
Method which takes an iterator and generates Self
from the elements by
“summing up” the items.
impl Sum<isize> for isize
impl Sum<usize> for usize
impl<'a> Sum<&'a f32> for f32
impl<'a> Sum<&'a f64> for f64
impl<'a> Sum<&'a i8> for i8
impl<'a> Sum<&'a i16> for i16
impl<'a> Sum<&'a i32> for i32
impl<'a> Sum<&'a i64> for i64
impl<'a> Sum<&'a i128> for i128
impl<'a> Sum<&'a isize> for isize
impl<'a> Sum<&'a u8> for u8
impl<'a> Sum<&'a u16> for u16
impl<'a> Sum<&'a u32> for u32
impl<'a> Sum<&'a u64> for u64
impl<'a> Sum<&'a u128> for u128
impl<'a> Sum<&'a usize> for usize