Skip to content

Commit

Permalink
Remove redundant uses of Iterator::by_ref()
Browse files Browse the repository at this point in the history
  • Loading branch information
bluss committed Sep 29, 2015
1 parent cff0411 commit e2aa82c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/libcollections/btree/node.rs
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
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
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
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

0 comments on commit e2aa82c

Please sign in to comment.