mlua/tests/compile_fail/scope_invariance.rs

24 lines
464 B
Rust
Raw Normal View History

2019-10-16 09:59:40 -04:00
use mlua::{Lua, Result};
struct Test {
field: i32,
}
fn main() {
let lua = Lua::new();
lua.scope(|scope| -> Result<()> {
let f = {
let mut test = Test { field: 0 };
scope
.create_function_mut(|_, ()| {
test.field = 42;
//~^ error: `test` does not live long enough
Ok(())
})?
};
f.call::<_, ()>(())
});
}