Skip to content

Commit 18878b1

Browse files
committed
std: Require &mut self for Iterator::all
Keeps the method consistent with `Iterator::any`. Closes #22617 [breaking-change]
1 parent ad04cce commit 18878b1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libcore/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,8 @@ pub trait IteratorExt: Iterator + Sized {
637637
/// ```
638638
#[inline]
639639
#[stable(feature = "rust1", since = "1.0.0")]
640-
fn all<F>(self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
641-
for x in self { if !f(x) { return false; } }
640+
fn all<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
641+
for x in self.by_ref() { if !f(x) { return false; } }
642642
true
643643
}
644644

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3883,7 +3883,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
38833883
let types_a = substs_a.types.get_slice(subst::TypeSpace);
38843884
let types_b = substs_b.types.get_slice(subst::TypeSpace);
38853885

3886-
let pairs = types_a.iter().zip(types_b.iter());
3886+
let mut pairs = types_a.iter().zip(types_b.iter());
38873887

38883888
pairs.all(|(&a, &b)| same_type(a, b))
38893889
}

0 commit comments

Comments
 (0)