blob: 88ffa5b0a93d95fa722b798064030fed5a0f148c (
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::{AnyUserData, Lua, Table, UserData};
fn main() {
let lua = Lua::new();
let globals = lua.globals();
// Should not allow userdata borrow to outlive lifetime of AnyUserData handle
struct MyUserData;
impl UserData for MyUserData {};
let userdata_ref;
{
let touter = globals.get::<_, Table>("touter").unwrap();
touter
.set("userdata", lua.create_userdata(MyUserData).unwrap())
.unwrap();
let userdata = touter.get::<_, AnyUserData>("userdata").unwrap();
userdata_ref = userdata.borrow::<MyUserData>();
//~^ error: `userdata` does not live long enough
}
}
|