// From https://github.com/dtolnay/reduce
pub trait Reduce<T> {
fn reduce<F>(self, f: F) -> Option<T>
where
Self: Sized,
F: FnMut(T, T) -> T;
}
impl<T, I> Reduce<T> for I
where
I: Iterator<Item = T>,
{
#[inline]
fn reduce<F>(mut self, f: F) -> Option<T>
where
Self: Sized,
F: FnMut(T, T) -> T,
{
self.next().map(|first| self.fold(first, f))
}
}