blob: 648411f9cb2ada092b62f6df41f6184ea8dc1e06 (
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() {
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
}
}
|