25 lines
741 B
Rust
25 lines
741 B
Rust
macro_rules! type_from_lua_userdata{
|
|
($asd:ident)=>{
|
|
impl<'lua> mlua::FromLua<'lua> for $asd{
|
|
fn from_lua(value:mlua::Value<'lua>,_lua:&'lua mlua::Lua)->Result<Self,mlua::Error>{
|
|
match value{
|
|
mlua::Value::UserData(ud)=>ud.take(),
|
|
other=>Err(mlua::Error::runtime(format!("Expected {} got {:?}",stringify!($asd),other))),
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
macro_rules! type_from_lua_userdata_lua_lifetime{
|
|
($asd:ident)=>{
|
|
impl<'lua> mlua::FromLua<'lua> for $asd<'lua>{
|
|
fn from_lua(value:mlua::Value<'lua>,_lua:&'lua mlua::Lua)->Result<Self,mlua::Error>{
|
|
match value{
|
|
mlua::Value::UserData(ud)=>ud.take(),
|
|
other=>Err(mlua::Error::runtime(format!("Expected {} got {:?}",stringify!($asd),other))),
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|