We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 797e8e3 commit eaa9c69Copy full SHA for eaa9c69
crates/macros/src/module.rs
@@ -35,11 +35,16 @@ pub fn parser(input: ItemFn) -> Result<TokenStream> {
35
let b = __EXT_PHP_RS_MODULE_STARTUP
36
.lock()
37
.take()
38
- .inspect(|_| ::ext_php_rs::internal::ext_php_rs_startup())
39
- .expect("Module startup function has already been called.")
40
- .startup(ty, mod_num)
41
- .map(|_| 0)
42
- .unwrap_or(1);
+ .map(|startup| {
+ ::ext_php_rs::internal::ext_php_rs_startup();
+ startup.startup(ty, mod_num).map(|_| 0).unwrap_or(1)
+ })
+ .unwrap_or_else(|| {
43
+ // Module already started, call ext_php_rs_startup for idempotent
44
+ // initialization (e.g., Closure::build early-returns if already built)
45
46
+ 0
47
+ });
48
a | b
49
}
50
0 commit comments