mlua
mlua copied to clipboard
Derive `FromLua`
While my use case might be a bit unusual (trying to implement the neovim api from lua, to write a plugin with mlua) the feature might have more useful use cases.
While Serialize
can provide conversion for some things, mapping a Struct to a table containing Function
s is not possible:
#[derive(FromLua)]
struct Api<'lua> {
pub nvim_get_autocmds: LuaFunction<'lua>,
}
This could be achieved by providing a derive macro for FromLua
.
I would be interested in implementing this.
mapping a Struct to a table containing Functions is not possible:
Could you explain please? You can implement To/From Lua for structs that contains references to Lua.
Also if you don't want dealing with lifetimes, you could try to use RegistryKey instead and store functions in registry using Lua::create_registry_value
mapping a Struct to a table containing Functions is not possible:
Could you explain please? You can implement To/From Lua for structs that contains references to Lua.
I know, and that is what I want to do. But it is only possible manually and not "derivable".
This is not about wanting a new feature, it's just about the derive macro.
yes, I think this is a good idea! I need the same thing.
I'm interested in working on this, and more. I'm currently writing an issue with more details