blob: fbf0e595d7ddfb5c09d3b5987fe8a7a2d9928a19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
extern crate rlua;
use rlua::{Lua, UserData};
fn main() {
let lua = Lua::new();
let globals = lua.globals();
// Should not allow userdata borrow to outlive lifetime of AnyUserData handle
struct MyUserData<'a>(&'a i32);
impl<'a> UserData for MyUserData<'a> {};
let igood = 1;
let lua = Lua::new();
lua.scope(|scope| {
let ugood = scope.create_nonstatic_userdata(MyUserData(&igood)).unwrap();
let ubad = {
let ibad = 42;
scope.create_nonstatic_userdata(MyUserData(&ibad)).unwrap();
//~^ error: `ibad` does not live long enough
};
});
}
|