mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
25 lines
1.1 KiB
Plaintext
25 lines
1.1 KiB
Plaintext
error[E0373]: closure may outlive the current function, but it borrows `test.field`, which is owned by the current function
|
|
--> tests/compile/scope_invariance.rs:13:39
|
|
|
|
|
9 | lua.scope(|scope| {
|
|
| ----- has type `&'1 mlua::Scope<'1, '_>`
|
|
...
|
|
13 | scope.create_function_mut(|_, ()| {
|
|
| ^^^^^^^ may outlive borrowed value `test.field`
|
|
14 | test.field = 42;
|
|
| ---------- `test.field` is borrowed here
|
|
|
|
|
note: function requires argument type to outlive `'1`
|
|
--> tests/compile/scope_invariance.rs:13:13
|
|
|
|
|
13 | / scope.create_function_mut(|_, ()| {
|
|
14 | | test.field = 42;
|
|
15 | | //~^ error: `test` does not live long enough
|
|
16 | | Ok(())
|
|
17 | | })?
|
|
| |______________^
|
|
help: to force the closure to take ownership of `test.field` (and any other referenced variables), use the `move` keyword
|
|
|
|
|
13 | scope.create_function_mut(move |_, ()| {
|
|
| ++++
|