]>
Commit | Line | Data |
---|---|---|
ff7c6d11 | 1 | error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function |
0731742a | 2 | --> $DIR/borrowck-escaping-closure-error-1.rs:13:11 |
ff7c6d11 | 3 | | |
0531ce1d | 4 | LL | spawn(|| books.push(4)); |
ff7c6d11 XL |
5 | | ^^ ----- `books` is borrowed here |
6 | | | | |
7 | | may outlive borrowed value `books` | |
48663c56 XL |
8 | | |
9 | note: function requires argument type to outlive `'static` | |
10 | --> $DIR/borrowck-escaping-closure-error-1.rs:13:5 | |
11 | | | |
12 | LL | spawn(|| books.push(4)); | |
13 | | ^^^^^^^^^^^^^^^^^^^^^^^ | |
ff7c6d11 XL |
14 | help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword |
15 | | | |
0531ce1d | 16 | LL | spawn(move || books.push(4)); |
94222f64 | 17 | | ++++ |
ff7c6d11 XL |
18 | |
19 | error: aborting due to previous error | |
20 | ||
0531ce1d | 21 | For more information about this error, try `rustc --explain E0373`. |