macro_rules! type_from_lua_userdata{ ($asd:ident)=>{ impl mlua::FromLua for $asd{ fn from_lua(value:mlua::Value,_lua:&mlua::Lua)->Result{ match value{ mlua::Value::UserData(ud)=>Ok(*ud.borrow::()?), other=>Err(mlua::Error::runtime(format!("Expected {} got {:?}",stringify!($asd),other))), } } } }; } macro_rules! type_from_lua_userdata_lua_lifetime{ ($asd:ident)=>{ impl mlua::FromLua for $asd<'static>{ fn from_lua(value:mlua::Value,_lua:&mlua::Lua)->Result{ match value{ mlua::Value::UserData(ud)=>Ok(*ud.borrow::()?), other=>Err(mlua::Error::runtime(format!("Expected {} got {:?}",stringify!($asd),other))), } } } }; }