mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
Remove redundant uses of Iterator::by_ref()
This commit is contained in:
@@ -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 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user