2020-07-27 05:49:01 -04:00
|
|
|
warning: unused variable: `old`
|
|
|
|
--> $DIR/scope_callback_capture.rs:9:29
|
|
|
|
|
|
|
|
|
9 | if let Some(old) = inner.take() {
|
|
|
|
| ^^^ help: if this is intentional, prefix it with an underscore: `_old`
|
|
|
|
|
|
|
|
|
= note: `#[warn(unused_variables)]` on by default
|
|
|
|
|
|
|
|
error[E0521]: borrowed data escapes outside of closure
|
2020-05-06 20:18:56 -04:00
|
|
|
--> $DIR/scope_callback_capture.rs:7:17
|
|
|
|
|
|
2020-07-27 05:49:01 -04:00
|
|
|
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<Table> = None;
|
|
|
|
7 | let f = scope
|
|
|
|
| _________________^
|
2020-05-06 20:18:56 -04:00
|
|
|
8 | | .create_function_mut(move |_, t: Table| {
|
2020-07-27 05:49:01 -04:00
|
|
|
9 | | if let Some(old) = inner.take() {
|
|
|
|
10 | | // Access old callback `Lua`.
|
2020-05-06 20:18:56 -04:00
|
|
|
... |
|
2020-07-27 05:49:01 -04:00
|
|
|
13 | | Ok(())
|
|
|
|
14 | | })?;
|
|
|
|
| |______________^ `scope` escapes the closure body here
|