2018-02-10 00:26:48 -05:00
|
|
|
extern crate rlua;
|
|
|
|
|
2018-09-16 20:15:51 -04:00
|
|
|
use rlua::Lua;
|
2018-02-10 00:26:48 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
struct Test {
|
|
|
|
field: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
let lua = Lua::new();
|
|
|
|
lua.scope(|scope| {
|
|
|
|
let f = {
|
|
|
|
let mut test = Test { field: 0 };
|
|
|
|
|
|
|
|
scope
|
|
|
|
.create_function_mut(|_, ()| {
|
|
|
|
test.field = 42;
|
|
|
|
//~^ error: `test` does not live long enough
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
};
|
|
|
|
|
|
|
|
f.call::<_, ()>(()).unwrap();
|
|
|
|
});
|
|
|
|
}
|