Skip to main content

module_entries

Function module_entries 

Source
pub fn module_entries() -> Vec<(&'static str, ModuleFactory)>
Expand description

Returns a list of (name, factory) pairs for all enabled modules.

Each entry is a (&'static str, fn(&Lua) -> LuaResult<LuaTable>). The list only includes modules whose cargo features are active.

§When to use

Use this when you need per-module registration instead of the all-in-one register_all. Common case: integration with mlua-pkg’s NativeResolver:

// `ignore`: NativeResolver is from the `mlua-pkg` crate, which is
// not a dependency of this crate. Cannot be compiled in-tree.
let mut resolver = NativeResolver::new();
for (name, factory) in mlua_batteries::module_entries() {
    resolver = resolver.add(name, |lua| factory(lua).map(mlua::Value::Table));
}