Open
Description
What it does
Check value that are matched by ref mut
but only immutable methods are called.
Advantage
- Reduce unnecessary mutability
Drawbacks
No response
Example
struct S;
impl S {
fn f(&self) {}
}
fn main() {
let mut x = Some(S);
if let Some(ref mut y) = x {
y.f();
}
}
Could be written as:
struct S;
impl S {
fn f(&self) {}
}
fn main() {
let mut x = Some(S);
if let Some(ref y) = x {
y.f();
}
}