diff --git a/src/module.rs b/src/module.rs index eff2151..8222e42 100644 --- a/src/module.rs +++ b/src/module.rs @@ -714,6 +714,13 @@ impl<'a> NotStartedModuleRef<'a> { } self.instance } + + /// Whether or not the module has a `start` function. + /// + /// Returns `true` if it has a `start` function. + pub fn has_start(&self) -> bool { + self.loaded_module.module().start_section().is_some() + } } fn eval_init_expr(init_expr: &InitExpr, module: &ModuleInstance) -> RuntimeValue { @@ -793,9 +800,9 @@ mod tests { (start $f)) "#, ); - ModuleInstance::new(&module_with_start, &ImportsBuilder::default()) - .unwrap() - .assert_no_start(); + let module = ModuleInstance::new(&module_with_start, &ImportsBuilder::default()).unwrap(); + assert!(!module.has_start()); + module.assert_no_start(); } #[test]