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