Skip to content

Commit fc65626

Browse files
committed
iterator: use advance to implement FilterMapIterator
1 parent 0732255 commit fc65626

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/libcore/iterator.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,13 @@ pub struct FilterMapIterator<'self, A, B, T> {
325325
impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMapIterator<'self, A, B, T> {
326326
#[inline]
327327
fn next(&mut self) -> Option<B> {
328-
loop {
329-
match self.iter.next() {
330-
None => { return None; }
331-
Some(a) => {
332-
match (self.f)(a) {
333-
Some(b) => { return Some(b); }
334-
None => { loop; }
335-
}
336-
}
328+
for self.iter.advance |x| {
329+
match (self.f)(x) {
330+
Some(y) => return Some(y),
331+
None => ()
337332
}
338333
}
334+
None
339335
}
340336
}
341337

0 commit comments

Comments
 (0)