Skip to content

Remove redundant uses of Iterator::by_ref() #28731

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 1 commit into from
Sep 30, 2015
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl<T> DoubleEndedIterator for RawItems<T> {

impl<T> Drop for RawItems<T> {
fn drop(&mut self) {
for _ in self.by_ref() {}
for _ in self {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {}
impl<T> Drop for IntoIter<T> {
fn drop(&mut self) {
// destroy the remaining elements
for _x in self.by_ref() {}
for _x in self {}

// RawVec handles deallocation
}
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub trait Iterator {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn nth(&mut self, mut n: usize) -> Option<Self::Item> where Self: Sized {
for x in self.by_ref() {
for x in self {
if n == 0 { return Some(x) }
n -= 1;
}
Expand Down Expand Up @@ -637,7 +637,7 @@ pub trait Iterator {
fn all<F>(&mut self, mut f: F) -> bool where
Self: Sized, F: FnMut(Self::Item) -> bool
{
for x in self.by_ref() {
for x in self {
if !f(x) {
return false;
}
Expand All @@ -664,7 +664,7 @@ pub trait Iterator {
Self: Sized,
F: FnMut(Self::Item) -> bool
{
for x in self.by_ref() {
for x in self {
if f(x) {
return true;
}
Expand All @@ -689,7 +689,7 @@ pub trait Iterator {
Self: Sized,
P: FnMut(&Self::Item) -> bool,
{
for x in self.by_ref() {
for x in self {
if predicate(&x) { return Some(x) }
}
None
Expand Down Expand Up @@ -725,7 +725,7 @@ pub trait Iterator {
P: FnMut(Self::Item) -> bool,
{
// `enumerate` might overflow.
for (i, x) in self.by_ref().enumerate() {
for (i, x) in self.enumerate() {
if predicate(x) {
return Some(i);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/collections/hash/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> {

impl<'a, K: 'a, V: 'a> Drop for Drain<'a, K, V> {
fn drop(&mut self) {
for _ in self.by_ref() {}
for _ in self {}
}
}

Expand Down