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