diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 88a729a3db0..80041006e8e 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1565,24 +1565,13 @@ pub struct Map { f: F, } -impl Map where F: FnMut(I::Item) -> B { - #[inline] - fn do_map(&mut self, elt: Option) -> Option { - match elt { - Some(a) => Some((self.f)(a)), - _ => None - } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for Map where F: FnMut(I::Item) -> B { type Item = B; #[inline] fn next(&mut self) -> Option { - let next = self.iter.next(); - self.do_map(next) + self.iter.next().map(|a| (self.f)(a)) } #[inline] @@ -1597,8 +1586,7 @@ impl DoubleEndedIterator for Map where { #[inline] fn next_back(&mut self) -> Option { - let next = self.iter.next_back(); - self.do_map(next) + self.iter.next_back().map(|a| (self.f)(a)) } } @@ -1613,8 +1601,7 @@ impl RandomAccessIterator for Map where #[inline] fn idx(&mut self, index: usize) -> Option { - let elt = self.iter.idx(index); - self.do_map(elt) + self.iter.idx(index).map(|a| (self.f)(a)) } }