1
Fork 0

Remove redundant uses of Iterator::by_ref()

This commit is contained in:
Ulrik Sverdrup 2015-09-29 17:12:42 +02:00
parent cff0411706
commit e2aa82c413
4 changed files with 8 additions and 8 deletions

View file

@ -271,7 +271,7 @@ impl<T> DoubleEndedIterator for RawItems<T> {
impl<T> Drop for RawItems<T> { impl<T> Drop for RawItems<T> {
fn drop(&mut self) { fn drop(&mut self) {
for _ in self.by_ref() {} for _ in self {}
} }
} }

View file

@ -1489,7 +1489,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {}
impl<T> Drop for IntoIter<T> { impl<T> Drop for IntoIter<T> {
fn drop(&mut self) { fn drop(&mut self) {
// destroy the remaining elements // destroy the remaining elements
for _x in self.by_ref() {} for _x in self {}
// RawVec handles deallocation // RawVec handles deallocation
} }

View file

@ -165,7 +165,7 @@ pub trait Iterator {
#[inline] #[inline]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn nth(&mut self, mut n: usize) -> Option<Self::Item> where Self: Sized { 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) } if n == 0 { return Some(x) }
n -= 1; n -= 1;
} }
@ -637,7 +637,7 @@ pub trait Iterator {
fn all<F>(&mut self, mut f: F) -> bool where fn all<F>(&mut self, mut f: F) -> bool where
Self: Sized, F: FnMut(Self::Item) -> bool Self: Sized, F: FnMut(Self::Item) -> bool
{ {
for x in self.by_ref() { for x in self {
if !f(x) { if !f(x) {
return false; return false;
} }
@ -664,7 +664,7 @@ pub trait Iterator {
Self: Sized, Self: Sized,
F: FnMut(Self::Item) -> bool F: FnMut(Self::Item) -> bool
{ {
for x in self.by_ref() { for x in self {
if f(x) { if f(x) {
return true; return true;
} }
@ -689,7 +689,7 @@ pub trait Iterator {
Self: Sized, Self: Sized,
P: FnMut(&Self::Item) -> bool, P: FnMut(&Self::Item) -> bool,
{ {
for x in self.by_ref() { for x in self {
if predicate(&x) { return Some(x) } if predicate(&x) { return Some(x) }
} }
None None
@ -725,7 +725,7 @@ pub trait Iterator {
P: FnMut(Self::Item) -> bool, P: FnMut(Self::Item) -> bool,
{ {
// `enumerate` might overflow. // `enumerate` might overflow.
for (i, x) in self.by_ref().enumerate() { for (i, x) in self.enumerate() {
if predicate(x) { if predicate(x) {
return Some(i); return Some(i);
} }

View file

@ -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> { impl<'a, K: 'a, V: 'a> Drop for Drain<'a, K, V> {
fn drop(&mut self) { fn drop(&mut self) {
for _ in self.by_ref() {} for _ in self {}
} }
} }