提交 3e6d7243 编写于 作者: B bors

Auto merge of #28731 - bluss:by-ref, r=alexcrichton

Remove redundant uses of Iterator::by_ref()
......@@ -276,7 +276,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 {}
}
}
......
......@@ -1503,7 +1503,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
}
......
......@@ -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 {}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册