Skip to content

Commit

Permalink
slightly more consistent style
Browse files Browse the repository at this point in the history
  • Loading branch information
dherman committed Nov 23, 2024
1 parent 8125e15 commit e41e317
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions crates/neon/src/sys/no_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/neon/src/sys/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
12 changes: 7 additions & 5 deletions crates/neon/src/sys/tsfn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ impl<T> Drop for ThreadsafeFunction<T> {
}

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(())
);
};
}
}

0 comments on commit e41e317

Please sign in to comment.