]>
Commit | Line | Data |
---|---|---|
136023e0 | 1 | // edition:2021 |
17df50a5 XL |
2 | |
3 | #[derive(Debug)] | |
4 | struct Point { | |
5 | x: i32, | |
6 | y: i32, | |
7 | } | |
8 | fn foo () -> impl FnMut()->() { | |
9 | let mut p = Point {x: 1, y: 2 }; | |
10 | let mut c = || { | |
11 | //~^ ERROR closure may outlive the current function, but it borrows `p` | |
12 | p.x+=5; | |
13 | println!("{:?}", p); | |
14 | }; | |
15 | c | |
16 | } | |
17 | fn main() { | |
18 | let c = foo(); | |
19 | c(); | |
20 | } |