mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
19 lines
429 B
Rust
19 lines
429 B
Rust
fn call_it<F>(f: F) where F: Fn() { f(); }
|
|
|
|
struct A;
|
|
|
|
impl A {
|
|
fn gen(&self) {}
|
|
fn gen_mut(&mut self) {}
|
|
}
|
|
|
|
fn main() {
|
|
let mut x = A;
|
|
call_it(|| {
|
|
call_it(|| x.gen());
|
|
call_it(|| x.gen_mut());
|
|
//~^ ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
|
|
//~| ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
|
|
});
|
|
}
|