Skip to content

Commit 3e6d724

Browse files
committed
Auto merge of rust-lang#28731 - bluss:by-ref, r=alexcrichton
Remove redundant uses of Iterator::by_ref()
2 parents 13dc6aa + e2aa82c commit 3e6d724

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/libcollections/btree/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<T> DoubleEndedIterator for RawItems<T> {
276276

277277
impl<T> Drop for RawItems<T> {
278278
fn drop(&mut self) {
279-
for _ in self.by_ref() {}
279+
for _ in self {}
280280
}
281281
}
282282

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {}
15031503
impl<T> Drop for IntoIter<T> {
15041504
fn drop(&mut self) {
15051505
// destroy the remaining elements
1506-
for _x in self.by_ref() {}
1506+
for _x in self {}
15071507

15081508
// RawVec handles deallocation
15091509
}

src/libcore/iter.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub trait Iterator {
165165
#[inline]
166166
#[stable(feature = "rust1", since = "1.0.0")]
167167
fn nth(&mut self, mut n: usize) -> Option<Self::Item> where Self: Sized {
168-
for x in self.by_ref() {
168+
for x in self {
169169
if n == 0 { return Some(x) }
170170
n -= 1;
171171
}
@@ -637,7 +637,7 @@ pub trait Iterator {
637637
fn all<F>(&mut self, mut f: F) -> bool where
638638
Self: Sized, F: FnMut(Self::Item) -> bool
639639
{
640-
for x in self.by_ref() {
640+
for x in self {
641641
if !f(x) {
642642
return false;
643643
}
@@ -664,7 +664,7 @@ pub trait Iterator {
664664
Self: Sized,
665665
F: FnMut(Self::Item) -> bool
666666
{
667-
for x in self.by_ref() {
667+
for x in self {
668668
if f(x) {
669669
return true;
670670
}
@@ -689,7 +689,7 @@ pub trait Iterator {
689689
Self: Sized,
690690
P: FnMut(&Self::Item) -> bool,
691691
{
692-
for x in self.by_ref() {
692+
for x in self {
693693
if predicate(&x) { return Some(x) }
694694
}
695695
None
@@ -725,7 +725,7 @@ pub trait Iterator {
725725
P: FnMut(Self::Item) -> bool,
726726
{
727727
// `enumerate` might overflow.
728-
for (i, x) in self.by_ref().enumerate() {
728+
for (i, x) in self.enumerate() {
729729
if predicate(x) {
730730
return Some(i);
731731
}

src/libstd/collections/hash/table.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> {
958958

959959
impl<'a, K: 'a, V: 'a> Drop for Drain<'a, K, V> {
960960
fn drop(&mut self) {
961-
for _ in self.by_ref() {}
961+
for _ in self {}
962962
}
963963
}
964964

0 commit comments

Comments
 (0)