diff --git a/crates/neon/src/sys/no_panic.rs b/crates/neon/src/sys/no_panic.rs index b5de6eeb2..19336e60e 100644 --- a/crates/neon/src/sys/no_panic.rs +++ b/crates/neon/src/sys/no_panic.rs @@ -254,17 +254,17 @@ unsafe fn panic_msg(panic: &Panic) -> Option<&str> { unsafe fn external_from_panic(env: Env, panic: Panic) -> Local { let fail = || fatal_error("Failed to create a neon::types::JsBox from a panic"); let mut result = MaybeUninit::uninit(); - let status = napi::create_external( + + if napi::create_external( env, Box::into_raw(Box::new(DebugSendWrapper::new(panic))).cast(), Some(finalize_panic), ptr::null_mut(), result.as_mut_ptr(), - ); - - match status { - Ok(()) => (), - Err(_) => fail(), + ) + .is_err() + { + fail(); } let external = result.assume_init(); diff --git a/crates/neon/src/sys/object.rs b/crates/neon/src/sys/object.rs index 98eb694e7..fe049c98f 100644 --- a/crates/neon/src/sys/object.rs +++ b/crates/neon/src/sys/object.rs @@ -7,7 +7,7 @@ use super::{ /// Mutates the `out` argument to refer to a `napi_value` containing a newly created JavaScript Object. pub unsafe fn new(out: &mut Local, env: Env) { - assert!(napi::create_object(env, out as *mut _).is_ok()); + assert_eq!(napi::create_object(env, out as *mut _), Ok(())); } #[cfg(feature = "napi-8")] diff --git a/crates/neon/src/sys/tsfn.rs b/crates/neon/src/sys/tsfn.rs index 99726e433..ce793b7f5 100644 --- a/crates/neon/src/sys/tsfn.rs +++ b/crates/neon/src/sys/tsfn.rs @@ -182,11 +182,13 @@ impl Drop for ThreadsafeFunction { } unsafe { - assert!(napi::release_threadsafe_function( - self.tsfn.0, - napi::ThreadsafeFunctionReleaseMode::Release, - ) - .is_ok()); + assert_eq!( + napi::release_threadsafe_function( + self.tsfn.0, + napi::ThreadsafeFunctionReleaseMode::Release, + ), + Ok(()) + ); }; } }