From 5c80b7aabbbcd140dfefee745a8bad41262ac753 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 9 Apr 2015 08:59:48 -0700 Subject: [PATCH] Simplify iterator logic for Fuse --- src/libcore/iter.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 527a7297f85..9f378748d20 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2197,13 +2197,9 @@ impl Iterator for Fuse where I: Iterator { if self.done { None } else { - match self.iter.next() { - None => { - self.done = true; - None - } - x => x - } + let next = self.iter.next(); + self.done = next.is_none(); + next } } @@ -2224,13 +2220,9 @@ impl DoubleEndedIterator for Fuse where I: DoubleEndedIterator { if self.done { None } else { - match self.iter.next_back() { - None => { - self.done = true; - None - } - x => x - } + let next = self.iter.next_back(); + self.done = next.is_none(); + next } } }