diff options
author | kyren <kerriganw@gmail.com> | 2018-09-04 03:40:13 -0400 |
---|---|---|
committer | kyren <kerriganw@gmail.com> | 2018-09-04 03:40:13 -0400 |
commit | bd00af2bac54633103e05fe96bbc055897f507c0 (patch) | |
tree | 0eed0d8b6a1fe20175149babd8719bf15bdf896d /src/conversion.rs | |
parent | 37165a8201734fb91cd23236b180ca26bd168b69 (diff) | |
download | mlua-bd00af2bac54633103e05fe96bbc055897f507c0.zip |
Initial design for non-'static scoped userdata
Uses the same UserData trait, and should at least in theory support everything
that 'static UserData does, except that any functions added that rely on
AnyUserData are pretty much useless.
Probably pretty slow and I'm not sure how to make it dramatically faster, which
is a shame because generally when you need non'-static userdata you might be
creating it kind of a lot (if it was long-lived, it would probably be 'static).
Haven't added tests yet, will do that next.
Diffstat (limited to 'src/conversion.rs')
-rw-r--r-- | src/conversion.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/conversion.rs b/src/conversion.rs index b65eb4f..b66a9f0 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -112,13 +112,13 @@ impl<'lua> FromLua<'lua> for AnyUserData<'lua> { } } -impl<'lua, T: Send + UserData> ToLua<'lua> for T { +impl<'lua, T: 'static + Send + UserData> ToLua<'lua> for T { fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> { Ok(Value::UserData(lua.create_userdata(self)?)) } } -impl<'lua, T: UserData + Clone> FromLua<'lua> for T { +impl<'lua, T: 'static + UserData + Clone> FromLua<'lua> for T { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<T> { match value { Value::UserData(ud) => Ok(ud.borrow::<T>()?.clone()), |