summaryrefslogtreecommitdiff
path: root/tests/compile-fail/scope_callback_escape.rs
blob: 2da9d6145d38b2844c37d84e5e3d578f48050772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extern crate rlua;

use rlua::*;

fn main() {
    struct Test {
        field: i32,
    }

    let lua = Lua::new();
    let mut outer: Option<Table> = None;
    lua.scope(|scope| {
        let f = scope
            .create_function_mut(|_, t: Table| {
                outer = Some(t);
                //~^ error: `*outer` does not live long enough
                Ok(())
            })
            .unwrap();
        f.call::<_, ()>(lua.create_table()).unwrap();
    });
}