about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-05-18 04:48:22 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-05-18 04:48:22 -0400
commitfc656262a905a50eff2be54a87295d2952d29106 (patch)
tree36c3f790a20a81c799392e126c9409756b0f5e6b /src
parent073225572a1c7c7dc9f7c2740514557105950807 (diff)
downloadrust-fc656262a905a50eff2be54a87295d2952d29106.tar.gz
rust-fc656262a905a50eff2be54a87295d2952d29106.zip
iterator: use advance to implement FilterMapIterator
Diffstat (limited to 'src')
-rw-r--r--src/libcore/iterator.rs14
1 files changed, 5 insertions, 9 deletions
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<A>> Iterator<B> for FilterMapIterator<'self, A, B, T> {
     #[inline]
     fn next(&mut self) -> Option<B> {
-        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
     }
 }