Skip to content

Commit

Permalink
Rollup merge of rust-lang#28191 - llogiq:iter, r=Manishearth
Browse files Browse the repository at this point in the history
Nothing too big, a few needless returns and a few closures eliminated (the latter may improve performance in some cases, at least compilation should be a bit faster).
  • Loading branch information
Manishearth committed Sep 3, 2015
2 parents 567e144 + e1f8919 commit 7fe48dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ impl<A, B> Iterator for Chain<A, B> where
fn next(&mut self) -> Option<A::Item> {
match self.state {
ChainState::Both => match self.a.next() {
elt @ Some(..) => return elt,
elt @ Some(..) => elt,
None => {
self.state = ChainState::Back;
self.b.next()
Expand Down Expand Up @@ -1590,7 +1590,7 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
fn next_back(&mut self) -> Option<A::Item> {
match self.state {
ChainState::Both => match self.b.next_back() {
elt @ Some(..) => return elt,
elt @ Some(..) => elt,
None => {
self.state = ChainState::Front;
self.a.next_back()
Expand Down Expand Up @@ -1683,7 +1683,7 @@ impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {

#[inline]
fn next(&mut self) -> Option<B> {
self.iter.next().map(|a| (self.f)(a))
self.iter.next().map(&mut self.f)
}

#[inline]
Expand All @@ -1698,7 +1698,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where
{
#[inline]
fn next_back(&mut self) -> Option<B> {
self.iter.next_back().map(|a| (self.f)(a))
self.iter.next_back().map(&mut self.f)
}
}

Expand Down Expand Up @@ -2210,7 +2210,7 @@ impl<I: Iterator, U: IntoIterator, F> Iterator for FlatMap<I, U, F>
return Some(x)
}
}
match self.iter.next().map(|x| (self.f)(x)) {
match self.iter.next().map(&mut self.f) {
None => return self.backiter.as_mut().and_then(|it| it.next()),
next => self.frontiter = next.map(IntoIterator::into_iter),
}
Expand Down Expand Up @@ -2243,7 +2243,7 @@ impl<I: DoubleEndedIterator, U, F> DoubleEndedIterator for FlatMap<I, U, F> wher
return Some(y)
}
}
match self.iter.next_back().map(|x| (self.f)(x)) {
match self.iter.next_back().map(&mut self.f) {
None => return self.frontiter.as_mut().and_then(|it| it.next_back()),
next => self.backiter = next.map(IntoIterator::into_iter),
}
Expand Down

0 comments on commit 7fe48dc

Please sign in to comment.