Skip to content

Commit 512ca9f

Browse files
committed
fix(closure): early-exit rather than assert if already built
1 parent 308f3c5 commit 512ca9f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/closure.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,16 @@ impl Closure {
115115
/// function should only be called once inside your module startup
116116
/// function.
117117
///
118+
/// If the class has already been built, this function returns early without
119+
/// doing anything. This allows for safe repeated calls in test environments.
120+
///
118121
/// # Panics
119122
///
120-
/// Panics if the function is called more than once.
123+
/// Panics if the `RustClosure` PHP class cannot be registered.
121124
pub fn build() {
122-
assert!(!CLOSURE_META.has_ce(), "Closure class already built.");
125+
if CLOSURE_META.has_ce() {
126+
return;
127+
}
123128

124129
ClassBuilder::new("RustClosure")
125130
.method(

0 commit comments

Comments
 (0)