Skip to content

clippy improvements to iterators #28191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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