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
+1 -1
View File
@@ -271,7 +271,7 @@ fn next_back(&mut self) -> Option<T> {
impl<T> Drop for RawItems<T> {
fn drop(&mut self) {
for _ in self.by_ref() {}
for _ in self {}
}
}
+1 -1
View File
@@ -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
}
+5 -5
View File
@@ -165,7 +165,7 @@ fn last(self) -> Option<Self::Item> where Self: Sized {
#[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;
}
@@ -637,7 +637,7 @@ fn fold<B, F>(self, init: B, mut f: F) -> B where
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;
}
@@ -664,7 +664,7 @@ fn any<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 true;
}
@@ -689,7 +689,7 @@ fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
{
for x in self.by_ref() {
for x in self {
if predicate(&x) { return Some(x) }
}
None
@@ -725,7 +725,7 @@ fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
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);
}
+1 -1
View File
@@ -958,7 +958,7 @@ fn len(&self) -> usize { self.table.size() }
impl<'a, K: 'a, V: 'a> Drop for Drain<'a, K, V> {
fn drop(&mut self) {
for _ in self.by_ref() {}
for _ in self {}
}
}