Merge pull request #31 from jonas-schievink/clone-userdata

Relax requirements for UserData to impl FromLua
This commit is contained in:
kyren 2017-07-30 14:57:35 -04:00 committed by GitHub
commit 8ba3886c96
1 changed files with 2 additions and 2 deletions

View File

@ -103,10 +103,10 @@ impl<'lua, T: UserData> ToLua<'lua> for T {
} }
} }
impl<'lua, T: UserData + Copy> FromLua<'lua> for T { impl<'lua, T: UserData + Clone> FromLua<'lua> for T {
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<T> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<T> {
match value { match value {
Value::UserData(ud) => Ok(*ud.borrow::<T>()?), Value::UserData(ud) => Ok(ud.borrow::<T>()?.clone()),
_ => Err(Error::FromLuaConversionError( _ => Err(Error::FromLuaConversionError(
"cannot convert lua value to userdata".to_owned(), "cannot convert lua value to userdata".to_owned(),
)), )),