The error message is a little more subtle - it iterdoes not borrow variably, but the result is iterborrowed with the change. This is because it Iterator::anytakes on a value selfvia a mutable link:
fn any<F>(&mut self, f: F) -> bool
where
F: FnMut(Self::Item) -> bool,
Here's the reproduction:
struct X;
impl X {
fn new() -> X { X }
fn predicate(&mut self) -> bool { true }
}
fn main() {
match () {
_ if X::new().predicate() => {}
_ => {}
}
}
, contains :
fn t(r: &[u8]) {
match r {
_ if r.contains(&b';') => {}
_ => {}
}
}
, , . - "", - , -, , .
, , MIR Rust.
. :