Simplify OnErr
iterator next
and next_back
This commit is contained in:
parent
174a9b2d40
commit
7a5f5b5061
1 changed files with 2 additions and 14 deletions
|
@ -38,13 +38,7 @@ impl<I, F, T, E> Iterator for OnErr<I, F> where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
match self.iter.next() {
|
self.iter.next().map(|r| r.map_err(|e| { (self.f)(&e); e }))
|
||||||
Some(Err(e)) => {
|
|
||||||
(self.f)(&e);
|
|
||||||
Some(Err(e))
|
|
||||||
},
|
|
||||||
other => other
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -65,13 +59,7 @@ impl<I, F, T, E> DoubleEndedIterator for OnErr<I, F> where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next_back(&mut self) -> Option<Self::Item> {
|
fn next_back(&mut self) -> Option<Self::Item> {
|
||||||
match self.iter.next_back() {
|
self.iter.next_back().map(|r| r.map_err(|e| { (self.f)(&e); e }))
|
||||||
Some(Err(e)) => {
|
|
||||||
(self.f)(&e);
|
|
||||||
Some(Err(e))
|
|
||||||
},
|
|
||||||
other => other
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue