summaryrefslogtreecommitdiff
path: root/tests/compile-fail/scope_callback_escape.rs
blob: 43c5226c90c4280abc97fa55fa1500207af42c0c (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| {
                //~^^ error: borrowed data cannot be stored outside of its closure
                outer = Some(t);
                Ok(())
            })
            .unwrap();
        f.call::<_, ()>(lua.create_table()).unwrap();
    });
}