pub fn require_module(
table: &mut modulestab,
modname: &str,
features: Option<&[String]>,
silent: i32,
) -> i32Expand description
Port of removemathfunc(MathFunc previous, MathFunc current) from Src/module.c:1267.
C body:
removemathfunc(MathFunc previous, MathFunc current)
{
if (previous)
previous->next = current->next;
else
mathfuncs = current->next;
zsfree(current->name);
zsfree(current->module);
zfree(current, sizeof(*current));
}Unlinks current from the global mathfuncs list and frees it.
Rust port: previous is unused since the underlying HashMap
removal doesn’t need predecessor tracking.
Port of require_module(const char *module, Feature_enables features, int silent) from Src/module.c:2344.
C body c:2342-2360:
mod_export int
require_module(const char *module, Feature_enables features, int silent)
{
Module m = NULL;
int ret = 0;
queue_signals();
m = find_module(module, FINDMOD_ALIASP, &module);
if (!m || !m->u.handle ||
(m->node.flags & MOD_UNLOAD))
ret = load_module(module, features, silent);
else
ret = do_module_features(m, features, 0);
unqueue_signals();
return ret;
}Two branches: when the module isn’t loaded yet (or is mid-unload),
route through load_module which runs the full setup → features →
boot lifecycle. When it’s already loaded, skip to
do_module_features to just enable the requested per-feature
surface — much cheaper.
Static-link analog of m->u.handle is MOD_INIT_B (boot ran):
once boot_module has fired, the module is “loaded” in zshrs’s
non-dlopen world.
WARNING: param names don’t match C — Rust=(table, modname, features, silent) vs C=(module, features, silent)