2022-08-23 18:12:37 -04:00
|
|
|
error[E0373]: closure may outlive the current function, but it borrows `test.0`, which is owned by the current function
|
2021-11-27 08:42:22 -05:00
|
|
|
--> tests/compile/function_borrow.rs:9:33
|
2019-10-16 09:59:40 -04:00
|
|
|
|
|
|
|
|
9 | let _ = lua.create_function(|_, ()| -> Result<i32> {
|
2022-08-23 18:12:37 -04:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^ may outlive borrowed value `test.0`
|
2019-10-16 09:59:40 -04:00
|
|
|
10 | Ok(test.0)
|
2022-08-23 18:12:37 -04:00
|
|
|
| ------ `test.0` is borrowed here
|
2019-10-16 09:59:40 -04:00
|
|
|
|
|
|
|
|
note: function requires argument type to outlive `'static`
|
2021-11-27 08:42:22 -05:00
|
|
|
--> tests/compile/function_borrow.rs:9:13
|
2019-10-16 09:59:40 -04:00
|
|
|
|
|
|
|
|
9 | let _ = lua.create_function(|_, ()| -> Result<i32> {
|
|
|
|
| _____________^
|
|
|
|
10 | | Ok(test.0)
|
|
|
|
11 | | });
|
|
|
|
| |______^
|
2022-08-23 18:12:37 -04:00
|
|
|
help: to force the closure to take ownership of `test.0` (and any other referenced variables), use the `move` keyword
|
2019-10-16 09:59:40 -04:00
|
|
|
|
|
|
|
|
9 | let _ = lua.create_function(move |_, ()| -> Result<i32> {
|
2021-11-27 08:42:22 -05:00
|
|
|
| ++++
|