mlua_derive: Group functionality in modules

Create new `chunk`, `userdata`, `module` modules.
This commit is contained in:
Alex Orlenko
2026-05-18 23:21:37 +01:00
parent 023e4c61d8
commit 6e7d6c78ed
8 changed files with 151 additions and 149 deletions
+12 -12
View File
@@ -13,19 +13,19 @@ pub fn from_lua(input: TokenStream) -> TokenStream {
};
quote! {
impl #impl_generics ::mlua::FromLua for #ident #ty_generics #where_clause {
#[inline]
fn from_lua(value: ::mlua::Value, _: &::mlua::Lua) -> ::mlua::Result<Self> {
match value {
::mlua::Value::UserData(ud) => Ok(ud.borrow::<Self>()?.clone()),
_ => Err(::mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: #ident_str.to_string(),
message: None,
}),
}
impl #impl_generics ::mlua::FromLua for #ident #ty_generics #where_clause {
#[inline]
fn from_lua(value: ::mlua::Value, _: &::mlua::Lua) -> ::mlua::Result<Self> {
match value {
::mlua::Value::UserData(ud) => Ok(ud.borrow::<Self>()?.clone()),
_ => Err(::mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: #ident_str.to_string(),
message: None,
}),
}
}
}
}
}
.into()
}