diff --git a/src/lib.rs b/src/lib.rs index 002e923..4219739 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -905,6 +905,13 @@ where for_both!(self, inner => inner.fold(init, f)) } + fn for_each(self, f: F) + where + F: FnMut(Self::Item), + { + for_both!(self, inner => inner.for_each(f)) + } + fn count(self) -> usize { for_both!(self, inner => inner.count()) } @@ -924,12 +931,48 @@ where for_both!(self, inner => inner.collect()) } + fn partition(self, f: F) -> (B, B) + where + B: Default + Extend, + F: FnMut(&Self::Item) -> bool, + { + for_both!(self, inner => inner.partition(f)) + } + fn all(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool, { for_both!(*self, ref mut inner => inner.all(f)) } + + fn any(&mut self, f: F) -> bool + where + F: FnMut(Self::Item) -> bool, + { + for_both!(*self, ref mut inner => inner.any(f)) + } + + fn find

(&mut self, predicate: P) -> Option + where + P: FnMut(&Self::Item) -> bool, + { + for_both!(*self, ref mut inner => inner.find(predicate)) + } + + fn find_map(&mut self, f: F) -> Option + where + F: FnMut(Self::Item) -> Option, + { + for_both!(*self, ref mut inner => inner.find_map(f)) + } + + fn position

(&mut self, predicate: P) -> Option + where + P: FnMut(Self::Item) -> bool, + { + for_both!(*self, ref mut inner => inner.position(predicate)) + } } impl DoubleEndedIterator for Either @@ -952,6 +995,13 @@ where { for_both!(self, inner => inner.rfold(init, f)) } + + fn rfind

(&mut self, predicate: P) -> Option + where + P: FnMut(&Self::Item) -> bool, + { + for_both!(*self, ref mut inner => inner.rfind(predicate)) + } } impl ExactSizeIterator for Either @@ -964,6 +1014,13 @@ where } } +impl iter::FusedIterator for Either +where + L: iter::FusedIterator, + R: iter::FusedIterator, +{ +} + #[cfg(any(test, feature = "use_std"))] /// `Either` implements `Read` if both `L` and `R` do. ///