From e41e3178c0df51efa3719a45cbead429fae4b5b2 Mon Sep 17 00:00:00 2001 From: David Herman Date: Fri, 22 Nov 2024 17:19:57 -0800 Subject: [PATCH] slightly more consistent style --- crates/neon/src/sys/no_panic.rs | 12 ++++++------ crates/neon/src/sys/object.rs | 2 +- crates/neon/src/sys/tsfn.rs | 12 +++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) 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(()) + ); }; } }