2018-05-03 13:26:58 -05:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
// Point at the captured immutable outer variable
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn foo(mut f: Box<dyn FnMut()>) {
|
2018-05-03 13:26:58 -05:00
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut y = true;
|
2020-05-21 19:00:00 -05:00
|
|
|
foo(Box::new(move || y = !y) as Box<_>);
|
2019-04-22 02:40:08 -05:00
|
|
|
//~^ ERROR cannot assign to `y`, as it is not declared as mutable
|
2018-05-03 13:26:58 -05:00
|
|
|
}
|