error[E0521]: borrowed data escapes outside of closure --> $DIR/scope_callback_inner.rs:7:17 | 5 | lua.scope(|scope| { | ----- | | | `scope` declared here, outside of the closure body | `scope` is a reference that is only valid in the closure body 6 | let mut inner: Option = None; 7 | let f = scope | _________________^ 8 | | .create_function_mut(|_, t: Table| { 9 | | inner = Some(t); 10 | | Ok(()) 11 | | })?; | |______________^ `scope` escapes the closure body here error[E0373]: closure may outlive the current function, but it borrows `inner`, which is owned by the current function --> $DIR/scope_callback_inner.rs:8:34 | 5 | lua.scope(|scope| { | ----- has type `&Scope<'_, '2>` ... 8 | .create_function_mut(|_, t: Table| { | ^^^^^^^^^^^^^ may outlive borrowed value `inner` 9 | inner = Some(t); | ----- `inner` is borrowed here | note: function requires argument type to outlive `'2` --> $DIR/scope_callback_inner.rs:7:17 | 7 | let f = scope | _________________^ 8 | | .create_function_mut(|_, t: Table| { 9 | | inner = Some(t); 10 | | Ok(()) 11 | | })?; | |______________^ help: to force the closure to take ownership of `inner` (and any other referenced variables), use the `move` keyword | 8 | .create_function_mut(move |_, t: Table| { | ^^^^^^^^^^^^^^^^^^