lint: immutable condition: add internally mutable test
This commit is contained in:
parent
1ea84c80c1
commit
814827113e
@ -94,8 +94,22 @@ fn used_immutable() {
|
||||
}
|
||||
}
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
fn maybe_i_mutate(i: &Cell<bool>) { unimplemented!() }
|
||||
|
||||
fn internally_mutable() {
|
||||
let b = Cell::new(true);
|
||||
|
||||
while b.get() { // b cannot be silently coerced to `bool`
|
||||
maybe_i_mutate(&b);
|
||||
println!("OK - Method call within condition");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
immutable_condition();
|
||||
unused_var();
|
||||
used_immutable();
|
||||
internally_mutable();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user