diff --git a/src/libcore/iterator.rs b/src/libcore/iterator.rs index 0bf61b66f75..41f916f2d15 100644 --- a/src/libcore/iterator.rs +++ b/src/libcore/iterator.rs @@ -325,17 +325,13 @@ pub struct FilterMapIterator<'self, A, B, T> { impl<'self, A, B, T: Iterator> Iterator for FilterMapIterator<'self, A, B, T> { #[inline] fn next(&mut self) -> Option { - loop { - match self.iter.next() { - None => { return None; } - Some(a) => { - match (self.f)(a) { - Some(b) => { return Some(b); } - None => { loop; } - } - } + for self.iter.advance |x| { + match (self.f)(x) { + Some(y) => return Some(y), + None => () } } + None } }