diff --git a/crates/neon/src/sys/array.rs b/crates/neon/src/sys/array.rs index 773fc195f..7994f872e 100644 --- a/crates/neon/src/sys/array.rs +++ b/crates/neon/src/sys/array.rs @@ -6,7 +6,7 @@ use super::{ }; pub unsafe fn new(out: &mut Local, env: Env, length: usize) { - let () = napi::create_array_with_length(env, length, out as *mut _).unwrap(); + napi::create_array_with_length(env, length, out as *mut _).unwrap(); } /// Gets the length of a `napi_value` containing a JavaScript Array. @@ -16,6 +16,6 @@ pub unsafe fn new(out: &mut Local, env: Env, length: usize) { /// exception. pub unsafe fn len(env: Env, array: Local) -> u32 { let mut len = 0; - let () = napi::get_array_length(env, array, &mut len as *mut _).unwrap(); + napi::get_array_length(env, array, &mut len as *mut _).unwrap(); len } diff --git a/crates/neon/src/sys/arraybuffer.rs b/crates/neon/src/sys/arraybuffer.rs index a3a306f91..9c9cf3a64 100644 --- a/crates/neon/src/sys/arraybuffer.rs +++ b/crates/neon/src/sys/arraybuffer.rs @@ -11,7 +11,7 @@ pub unsafe fn new(env: Env, len: usize) -> Result { let mut buf = MaybeUninit::uninit(); let status = napi::create_arraybuffer(env, len, null_mut(), buf.as_mut_ptr()); - let () = match status { + match status { Err(err @ napi::Status::PendingException) => return Err(err), status => status.unwrap(), }; @@ -30,7 +30,7 @@ where let length = buf.len(); let mut result = MaybeUninit::uninit(); - let () = napi::create_external_arraybuffer( + napi::create_external_arraybuffer( env, buf.as_mut_ptr() as *mut _, length, @@ -55,7 +55,7 @@ pub unsafe fn as_mut_slice<'a>(env: Env, buf: Local) -> &'a mut [u8] { let mut data = MaybeUninit::uninit(); let mut size = 0usize; - let () = napi::get_arraybuffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); + napi::get_arraybuffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); if size == 0 { return &mut []; @@ -70,7 +70,7 @@ pub unsafe fn size(env: Env, buf: Local) -> usize { let mut data = MaybeUninit::uninit(); let mut size = 0usize; - let () = napi::get_arraybuffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); + napi::get_arraybuffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); size } diff --git a/crates/neon/src/sys/async_work.rs b/crates/neon/src/sys/async_work.rs index 710c3633f..10cec23ea 100644 --- a/crates/neon/src/sys/async_work.rs +++ b/crates/neon/src/sys/async_work.rs @@ -58,7 +58,7 @@ pub unsafe fn schedule( let work = &mut data.work as *mut _; // Create the `async_work` - let () = napi::create_async_work( + napi::create_async_work( env, ptr::null_mut(), super::string(env, "neon_async_work"), diff --git a/crates/neon/src/sys/buffer.rs b/crates/neon/src/sys/buffer.rs index 945de65eb..9586f8fb5 100644 --- a/crates/neon/src/sys/buffer.rs +++ b/crates/neon/src/sys/buffer.rs @@ -20,7 +20,7 @@ pub unsafe fn uninitialized(env: Env, len: usize) -> Result<(Local, *mut u8), na let mut bytes = MaybeUninit::uninit(); let status = napi::create_buffer(env, len, bytes.as_mut_ptr(), buf.as_mut_ptr()); - let () = match status { + match status { Err(err @ napi::Status::PendingException) => return Err(err), status => status.unwrap(), }; @@ -64,7 +64,7 @@ pub unsafe fn as_mut_slice<'a>(env: Env, buf: Local) -> &'a mut [u8] { let mut data = MaybeUninit::uninit(); let mut size = 0usize; - let () = napi::get_buffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); + napi::get_buffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); if size == 0 { return &mut []; @@ -79,7 +79,7 @@ pub unsafe fn size(env: Env, buf: Local) -> usize { let mut data = MaybeUninit::uninit(); let mut size = 0usize; - let () = napi::get_buffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); + napi::get_buffer_info(env, buf, data.as_mut_ptr(), &mut size as *mut _).unwrap(); size } diff --git a/crates/neon/src/sys/call.rs b/crates/neon/src/sys/call.rs index de68aa62f..c4b249bf0 100644 --- a/crates/neon/src/sys/call.rs +++ b/crates/neon/src/sys/call.rs @@ -33,7 +33,7 @@ impl Arguments { pub unsafe fn is_construct(env: Env, info: FunctionCallbackInfo) -> bool { let mut target: MaybeUninit = MaybeUninit::zeroed(); - let () = napi::get_new_target(env, info, target.as_mut_ptr()).unwrap(); + napi::get_new_target(env, info, target.as_mut_ptr()).unwrap(); // get_new_target is guaranteed to assign to target, so it's initialized. let target: Local = target.assume_init(); @@ -45,15 +45,14 @@ pub unsafe fn is_construct(env: Env, info: FunctionCallbackInfo) -> bool { } pub unsafe fn this(env: Env, info: FunctionCallbackInfo, out: &mut Local) { - let () = - napi::get_cb_info(env, info, null_mut(), null_mut(), out as *mut _, null_mut()).unwrap(); + napi::get_cb_info(env, info, null_mut(), null_mut(), out as *mut _, null_mut()).unwrap(); } /// Gets the number of arguments passed to the function. // TODO: Remove this when `FunctionContext` is refactored to get call info upfront. pub unsafe fn len(env: Env, info: FunctionCallbackInfo) -> usize { let mut argc = 0usize; - let () = napi::get_cb_info( + napi::get_cb_info( env, info, &mut argc as *mut _, @@ -73,7 +72,7 @@ pub unsafe fn argv(env: Env, info: FunctionCallbackInfo) -> Arguments { // Starts as the size allocated; after `get_cb_info` it is the number of arguments let mut argc = ARGV_SIZE; - let () = napi::get_cb_info( + napi::get_cb_info( env, info, &mut argc as *mut _, @@ -88,7 +87,7 @@ pub unsafe fn argv(env: Env, info: FunctionCallbackInfo) -> Arguments { // We know exactly how much space to reserve let mut argv = Vec::with_capacity(argc); - let () = napi::get_cb_info( + napi::get_cb_info( env, info, &mut argc as *mut _, diff --git a/crates/neon/src/sys/date.rs b/crates/neon/src/sys/date.rs index ed0b62b47..a8fa17cf2 100644 --- a/crates/neon/src/sys/date.rs +++ b/crates/neon/src/sys/date.rs @@ -12,7 +12,7 @@ use super::{ /// `env` is a raw pointer. Please ensure it points to a napi_env that is valid for the current context. pub unsafe fn new_date(env: Env, value: f64) -> Local { let mut local = MaybeUninit::zeroed(); - let () = napi::create_date(env, value, local.as_mut_ptr()).unwrap(); + napi::create_date(env, value, local.as_mut_ptr()).unwrap(); local.assume_init() } @@ -24,6 +24,6 @@ pub unsafe fn new_date(env: Env, value: f64) -> Local { /// `Local` must be an NAPI value associated with the given `Env` pub unsafe fn value(env: Env, p: Local) -> f64 { let mut value = 0.0; - let () = napi::get_date_value(env, p, &mut value as *mut _).unwrap(); + napi::get_date_value(env, p, &mut value as *mut _).unwrap(); value } diff --git a/crates/neon/src/sys/error.rs b/crates/neon/src/sys/error.rs index 8a9559d95..ee9beb424 100644 --- a/crates/neon/src/sys/error.rs +++ b/crates/neon/src/sys/error.rs @@ -8,7 +8,7 @@ use super::{ pub unsafe fn is_throwing(env: Env) -> bool { let mut b: MaybeUninit = MaybeUninit::zeroed(); - let () = napi::is_exception_pending(env, b.as_mut_ptr()).unwrap(); + napi::is_exception_pending(env, b.as_mut_ptr()).unwrap(); b.assume_init() } @@ -18,55 +18,55 @@ pub unsafe fn catch_error(env: Env, error: *mut Local) -> bool { return false; } - let () = napi::get_and_clear_last_exception(env, error).unwrap(); + napi::get_and_clear_last_exception(env, error).unwrap(); true } pub unsafe fn clear_exception(env: Env) { let mut result = MaybeUninit::uninit(); - let () = napi::is_exception_pending(env, result.as_mut_ptr()).unwrap(); + napi::is_exception_pending(env, result.as_mut_ptr()).unwrap(); if !result.assume_init() { return; } let mut result = MaybeUninit::uninit(); - let () = napi::get_and_clear_last_exception(env, result.as_mut_ptr()).unwrap(); + napi::get_and_clear_last_exception(env, result.as_mut_ptr()).unwrap(); } pub unsafe fn throw(env: Env, val: Local) { - let () = napi::throw(env, val).unwrap(); + napi::throw(env, val).unwrap(); } pub unsafe fn new_error(env: Env, out: &mut Local, msg: Local) { let mut result = MaybeUninit::uninit(); - let () = napi::create_error(env, ptr::null_mut(), msg, result.as_mut_ptr()).unwrap(); + napi::create_error(env, ptr::null_mut(), msg, result.as_mut_ptr()).unwrap(); *out = result.assume_init(); } pub unsafe fn new_type_error(env: Env, out: &mut Local, msg: Local) { let mut result = MaybeUninit::uninit(); - let () = napi::create_type_error(env, ptr::null_mut(), msg, result.as_mut_ptr()).unwrap(); + napi::create_type_error(env, ptr::null_mut(), msg, result.as_mut_ptr()).unwrap(); *out = result.assume_init(); } pub unsafe fn new_range_error(env: Env, out: &mut Local, msg: Local) { let mut result = MaybeUninit::uninit(); - let () = napi::create_range_error(env, ptr::null_mut(), msg, result.as_mut_ptr()).unwrap(); + napi::create_range_error(env, ptr::null_mut(), msg, result.as_mut_ptr()).unwrap(); *out = result.assume_init(); } pub unsafe fn throw_error_from_utf8(env: Env, msg: *const u8, len: i32) { let mut out = MaybeUninit::uninit(); - let () = - napi::create_string_utf8(env, msg as *const _, len as usize, out.as_mut_ptr()).unwrap(); + + napi::create_string_utf8(env, msg as *const _, len as usize, out.as_mut_ptr()).unwrap(); let mut err = MaybeUninit::uninit(); - let () = napi::create_error(env, ptr::null_mut(), out.assume_init(), err.as_mut_ptr()).unwrap(); + napi::create_error(env, ptr::null_mut(), out.assume_init(), err.as_mut_ptr()).unwrap(); throw(env, err.assume_init()); } diff --git a/crates/neon/src/sys/external.rs b/crates/neon/src/sys/external.rs index 607b6cf42..9d7b9407c 100644 --- a/crates/neon/src/sys/external.rs +++ b/crates/neon/src/sys/external.rs @@ -30,7 +30,7 @@ extern "C" fn finalize_external( /// pub unsafe fn deref(env: Env, local: Local) -> Option<*const T> { let mut result = MaybeUninit::uninit(); - let () = napi::typeof_value(env, local, result.as_mut_ptr()).unwrap(); + napi::typeof_value(env, local, result.as_mut_ptr()).unwrap(); let result = result.assume_init(); @@ -48,7 +48,7 @@ pub unsafe fn deref(env: Env, local: Local) -> Option<*const T> { } let mut result = MaybeUninit::uninit(); - let () = napi::get_value_external(env, local, result.as_mut_ptr()).unwrap(); + napi::get_value_external(env, local, result.as_mut_ptr()).unwrap(); let v = result.assume_init(); let v = &**v.cast_const().cast::>() as *const T; @@ -73,7 +73,7 @@ pub unsafe fn create(env: Env, v: T, finalizer: fn(Env, T)) -> Local // `napi_create_external` will only fail if the VM is in a throwing state // or shutting down. - let () = status.unwrap(); + status.unwrap(); let external = result.assume_init(); diff --git a/crates/neon/src/sys/fun.rs b/crates/neon/src/sys/fun.rs index 6723c9231..9d240333e 100644 --- a/crates/neon/src/sys/fun.rs +++ b/crates/neon/src/sys/fun.rs @@ -22,7 +22,7 @@ where out.as_mut_ptr(), ); - let () = match status { + match status { Err(err @ napi::Status::PendingException) => { drop(Box::from_raw(data)); @@ -55,7 +55,7 @@ where // If adding the finalizer fails the closure will leak, but it would // be unsafe to drop it because there's no guarantee V8 won't use the // pointer. - let () = status.unwrap(); + status.unwrap(); } Ok(out) @@ -68,7 +68,7 @@ where F: Fn(Env, napi::CallbackInfo) -> Local + 'static, { let mut data = MaybeUninit::uninit(); - let () = napi::get_cb_info( + napi::get_cb_info( env, info, ptr::null_mut(), diff --git a/crates/neon/src/sys/lifecycle.rs b/crates/neon/src/sys/lifecycle.rs index 40dbf06d5..f568b9138 100644 --- a/crates/neon/src/sys/lifecycle.rs +++ b/crates/neon/src/sys/lifecycle.rs @@ -17,8 +17,7 @@ use super::{bindings as napi, raw::Env}; pub unsafe fn set_instance_data(env: Env, data: T) -> *mut T { let data = Box::into_raw(Box::new(data)); - let () = - napi::set_instance_data(env, data.cast(), Some(drop_box::), ptr::null_mut()).unwrap(); + napi::set_instance_data(env, data.cast(), Some(drop_box::), ptr::null_mut()).unwrap(); data } @@ -31,7 +30,7 @@ pub unsafe fn set_instance_data(env: Env, data: T) -> *mut T pub unsafe fn get_instance_data(env: Env) -> *mut T { let mut data = MaybeUninit::uninit(); - let () = napi::get_instance_data(env, data.as_mut_ptr()).unwrap(); + napi::get_instance_data(env, data.as_mut_ptr()).unwrap(); data.assume_init().cast() } diff --git a/crates/neon/src/sys/mem.rs b/crates/neon/src/sys/mem.rs index 43af99b78..2774fdf4d 100644 --- a/crates/neon/src/sys/mem.rs +++ b/crates/neon/src/sys/mem.rs @@ -5,6 +5,6 @@ use super::{ pub unsafe fn strict_equals(env: Env, lhs: Local, rhs: Local) -> bool { let mut result = false; - let () = napi::strict_equals(env, lhs, rhs, &mut result as *mut _).unwrap(); + napi::strict_equals(env, lhs, rhs, &mut result as *mut _).unwrap(); result } diff --git a/crates/neon/src/sys/mod.rs b/crates/neon/src/sys/mod.rs index 5dd161a8f..6155e0b09 100644 --- a/crates/neon/src/sys/mod.rs +++ b/crates/neon/src/sys/mod.rs @@ -113,7 +113,7 @@ unsafe fn string(env: Env, s: impl AsRef) -> raw::Local { let s = s.as_ref(); let mut result = MaybeUninit::uninit(); - let () = create_string_utf8( + create_string_utf8( env, s.as_bytes().as_ptr() as *const _, s.len(), diff --git a/crates/neon/src/sys/primitive.rs b/crates/neon/src/sys/primitive.rs index 2a5b25436..d61fd8892 100644 --- a/crates/neon/src/sys/primitive.rs +++ b/crates/neon/src/sys/primitive.rs @@ -5,17 +5,17 @@ use super::{ /// Mutates the `out` argument provided to refer to the global `undefined` object. pub unsafe fn undefined(out: &mut Local, env: Env) { - let () = napi::get_undefined(env, out as *mut Local).unwrap(); + napi::get_undefined(env, out as *mut Local).unwrap(); } /// Mutates the `out` argument provided to refer to the global `null` object. pub unsafe fn null(out: &mut Local, env: Env) { - let () = napi::get_null(env, out as *mut Local).unwrap(); + napi::get_null(env, out as *mut Local).unwrap(); } /// Mutates the `out` argument provided to refer to one of the global `true` or `false` objects. pub unsafe fn boolean(out: &mut Local, env: Env, b: bool) { - let () = napi::get_boolean(env, b, out as *mut Local).unwrap(); + napi::get_boolean(env, b, out as *mut Local).unwrap(); } /// Get the boolean value out of a `Local` object. If the `Local` object does not contain a @@ -32,13 +32,13 @@ pub unsafe fn boolean_value(env: Env, p: Local) -> bool { /// Mutates the `out` argument provided to refer to a newly created `Local` containing a /// JavaScript number. pub unsafe fn number(out: &mut Local, env: Env, v: f64) { - let () = napi::create_double(env, v, out as *mut Local).unwrap(); + napi::create_double(env, v, out as *mut Local).unwrap(); } /// Gets the underlying value of an `Local` object containing a JavaScript number. Panics if /// the given `Local` is not a number. pub unsafe fn number_value(env: Env, p: Local) -> f64 { let mut value = 0.0; - let () = napi::get_value_double(env, p, &mut value as *mut f64).unwrap(); + napi::get_value_double(env, p, &mut value as *mut f64).unwrap(); value } diff --git a/crates/neon/src/sys/promise.rs b/crates/neon/src/sys/promise.rs index c054045d6..3b9631cb6 100644 --- a/crates/neon/src/sys/promise.rs +++ b/crates/neon/src/sys/promise.rs @@ -15,7 +15,7 @@ pub unsafe fn create(env: Env) -> (napi::Deferred, napi::Value) { let mut deferred = MaybeUninit::uninit(); let mut promise = MaybeUninit::uninit(); - let () = napi::create_promise(env, deferred.as_mut_ptr(), promise.as_mut_ptr()).unwrap(); + napi::create_promise(env, deferred.as_mut_ptr(), promise.as_mut_ptr()).unwrap(); (deferred.assume_init(), promise.assume_init()) } @@ -26,7 +26,7 @@ pub unsafe fn create(env: Env) -> (napi::Deferred, napi::Value) { /// * `env` is a valid `napi_env` for the current thread /// * `resolution` is a valid `napi::Value` pub unsafe fn resolve(env: Env, deferred: napi::Deferred, resolution: napi::Value) { - let () = napi::resolve_deferred(env, deferred, resolution).unwrap(); + napi::resolve_deferred(env, deferred, resolution).unwrap(); } /// Rejects a promise from a `napi::Deferred` handle @@ -35,7 +35,7 @@ pub unsafe fn resolve(env: Env, deferred: napi::Deferred, resolution: napi::Valu /// * `env` is a valid `napi_env` for the current thread /// * `rejection` is a valid `napi::Value` pub unsafe fn reject(env: Env, deferred: napi::Deferred, rejection: napi::Value) { - let () = napi::reject_deferred(env, deferred, rejection).unwrap(); + napi::reject_deferred(env, deferred, rejection).unwrap(); } #[cfg(feature = "napi-6")] @@ -47,7 +47,7 @@ pub unsafe fn reject_err_message(env: Env, deferred: napi::Deferred, msg: impl A let msg = super::string(env, msg); let mut err = MaybeUninit::uninit(); - let () = napi::create_error(env, std::ptr::null_mut(), msg, err.as_mut_ptr()).unwrap(); + napi::create_error(env, std::ptr::null_mut(), msg, err.as_mut_ptr()).unwrap(); reject(env, deferred, err.assume_init()); } diff --git a/crates/neon/src/sys/reference.rs b/crates/neon/src/sys/reference.rs index ab2e9d678..a290cdd8a 100644 --- a/crates/neon/src/sys/reference.rs +++ b/crates/neon/src/sys/reference.rs @@ -8,7 +8,7 @@ use super::{ pub unsafe fn new(env: Env, value: Local) -> napi::Ref { let mut result = MaybeUninit::uninit(); - let () = napi::create_reference(env, value, 1, result.as_mut_ptr()).unwrap(); + napi::create_reference(env, value, 1, result.as_mut_ptr()).unwrap(); result.assume_init() } @@ -18,7 +18,7 @@ pub unsafe fn new(env: Env, value: Local) -> napi::Ref { pub unsafe fn reference(env: Env, value: napi::Ref) -> usize { let mut result = MaybeUninit::uninit(); - let () = napi::reference_ref(env, value, result.as_mut_ptr()).unwrap(); + napi::reference_ref(env, value, result.as_mut_ptr()).unwrap(); result.assume_init() as usize } @@ -28,7 +28,7 @@ pub unsafe fn reference(env: Env, value: napi::Ref) -> usize { pub unsafe fn unreference(env: Env, value: napi::Ref) { let mut result = MaybeUninit::uninit(); - let () = napi::reference_unref(env, value, result.as_mut_ptr()).unwrap(); + napi::reference_unref(env, value, result.as_mut_ptr()).unwrap(); if result.assume_init() == 0 { assert_eq!(napi::delete_reference(env, value), Ok(())); @@ -40,7 +40,7 @@ pub unsafe fn unreference(env: Env, value: napi::Ref) { pub unsafe fn get(env: Env, value: napi::Ref) -> Local { let mut result = MaybeUninit::uninit(); - let () = napi::get_reference_value(env, value, result.as_mut_ptr()).unwrap(); + napi::get_reference_value(env, value, result.as_mut_ptr()).unwrap(); result.assume_init() } diff --git a/crates/neon/src/sys/scope.rs b/crates/neon/src/sys/scope.rs index c7d24fec9..4c690347f 100644 --- a/crates/neon/src/sys/scope.rs +++ b/crates/neon/src/sys/scope.rs @@ -14,7 +14,7 @@ impl HandleScope { pub(crate) unsafe fn new(env: Env) -> Self { let mut scope = MaybeUninit::uninit(); - let () = napi::open_handle_scope(env, scope.as_mut_ptr()).unwrap(); + napi::open_handle_scope(env, scope.as_mut_ptr()).unwrap(); Self { env, @@ -42,7 +42,7 @@ impl EscapableHandleScope { pub(crate) unsafe fn new(env: Env) -> Self { let mut scope = MaybeUninit::uninit(); - let () = napi::open_escapable_handle_scope(env, scope.as_mut_ptr()).unwrap(); + napi::open_escapable_handle_scope(env, scope.as_mut_ptr()).unwrap(); Self { env, @@ -53,7 +53,7 @@ impl EscapableHandleScope { pub(crate) unsafe fn escape(&self, value: napi::Value) -> napi::Value { let mut escapee = MaybeUninit::uninit(); - let () = napi::escape_handle(self.env, self.scope, value, escapee.as_mut_ptr()).unwrap(); + napi::escape_handle(self.env, self.scope, value, escapee.as_mut_ptr()).unwrap(); escapee.assume_init() } @@ -70,5 +70,5 @@ impl Drop for EscapableHandleScope { } pub unsafe fn get_global(env: Env, out: &mut Local) { - let () = super::get_global(env, out as *mut _).unwrap(); + super::get_global(env, out as *mut _).unwrap(); } diff --git a/crates/neon/src/sys/string.rs b/crates/neon/src/sys/string.rs index 6edcf7756..68e441f38 100644 --- a/crates/neon/src/sys/string.rs +++ b/crates/neon/src/sys/string.rs @@ -13,30 +13,30 @@ pub unsafe fn new(out: &mut Local, env: Env, data: *const u8, len: i32) -> bool pub unsafe fn utf8_len(env: Env, value: Local) -> usize { let mut len = MaybeUninit::uninit(); - let () = napi::get_value_string_utf8(env, value, ptr::null_mut(), 0, len.as_mut_ptr()).unwrap(); + napi::get_value_string_utf8(env, value, ptr::null_mut(), 0, len.as_mut_ptr()).unwrap(); len.assume_init() } pub unsafe fn data(env: Env, out: *mut u8, len: usize, value: Local) -> usize { let mut read = MaybeUninit::uninit(); - let () = - napi::get_value_string_utf8(env, value, out as *mut _, len, read.as_mut_ptr()).unwrap(); + + napi::get_value_string_utf8(env, value, out as *mut _, len, read.as_mut_ptr()).unwrap(); read.assume_init() } pub unsafe fn utf16_len(env: Env, value: Local) -> usize { let mut len = MaybeUninit::uninit(); - let () = - napi::get_value_string_utf16(env, value, ptr::null_mut(), 0, len.as_mut_ptr()).unwrap(); + + napi::get_value_string_utf16(env, value, ptr::null_mut(), 0, len.as_mut_ptr()).unwrap(); len.assume_init() } pub unsafe fn data_utf16(env: Env, out: *mut u16, len: usize, value: Local) -> usize { let mut read = MaybeUninit::uninit(); - let () = napi::get_value_string_utf16(env, value, out, len, read.as_mut_ptr()).unwrap(); + napi::get_value_string_utf16(env, value, out, len, read.as_mut_ptr()).unwrap(); read.assume_init() } diff --git a/crates/neon/src/sys/tag.rs b/crates/neon/src/sys/tag.rs index 6152ccc5d..3dcc888c0 100644 --- a/crates/neon/src/sys/tag.rs +++ b/crates/neon/src/sys/tag.rs @@ -6,7 +6,7 @@ use super::{ /// Return true if an `napi_value` `val` has the expected value type. unsafe fn is_type(env: Env, val: Local, expect: napi::ValueType) -> bool { let mut actual = napi::ValueType::Undefined; - let () = napi::typeof_value(env, val, &mut actual as *mut _).unwrap(); + napi::typeof_value(env, val, &mut actual as *mut _).unwrap(); actual == expect } @@ -49,35 +49,35 @@ pub unsafe fn is_function(env: Env, val: Local) -> bool { pub unsafe fn is_error(env: Env, val: Local) -> bool { let mut result = false; - let () = napi::is_error(env, val, &mut result as *mut _).unwrap(); + napi::is_error(env, val, &mut result as *mut _).unwrap(); result } /// Is `val` a Node.js Buffer instance? pub unsafe fn is_buffer(env: Env, val: Local) -> bool { let mut result = false; - let () = napi::is_buffer(env, val, &mut result as *mut _).unwrap(); + napi::is_buffer(env, val, &mut result as *mut _).unwrap(); result } /// Is `val` an ArrayBuffer instance? pub unsafe fn is_arraybuffer(env: Env, val: Local) -> bool { let mut result = false; - let () = napi::is_arraybuffer(env, val, &mut result as *mut _).unwrap(); + napi::is_arraybuffer(env, val, &mut result as *mut _).unwrap(); result } /// Is `val` a TypedArray instance? pub unsafe fn is_typedarray(env: Env, val: Local) -> bool { let mut result = false; - let () = napi::is_typedarray(env, val, &mut result as *mut _).unwrap(); + napi::is_typedarray(env, val, &mut result as *mut _).unwrap(); result } #[cfg(feature = "napi-5")] pub unsafe fn is_date(env: Env, val: Local) -> bool { let mut result = false; - let () = napi::is_date(env, val, &mut result as *mut _).unwrap(); + napi::is_date(env, val, &mut result as *mut _).unwrap(); result } @@ -87,20 +87,20 @@ pub unsafe fn is_date(env: Env, val: Local) -> bool { /// * `env` is a valid `napi_env` for the current thread pub unsafe fn is_promise(env: Env, val: Local) -> bool { let mut result = false; - let () = napi::is_promise(env, val, &mut result as *mut _).unwrap(); + napi::is_promise(env, val, &mut result as *mut _).unwrap(); result } #[cfg(feature = "napi-8")] pub unsafe fn type_tag_object(env: Env, object: Local, tag: &super::TypeTag) { - let () = napi::type_tag_object(env, object, tag as *const _).unwrap(); + napi::type_tag_object(env, object, tag as *const _).unwrap(); } #[cfg(feature = "napi-8")] pub unsafe fn check_object_type_tag(env: Env, object: Local, tag: &super::TypeTag) -> bool { let mut result = false; - let () = - napi::check_object_type_tag(env, object, tag as *const _, &mut result as *mut _).unwrap(); + + napi::check_object_type_tag(env, object, tag as *const _, &mut result as *mut _).unwrap(); result } diff --git a/crates/neon/src/sys/tsfn.rs b/crates/neon/src/sys/tsfn.rs index 5562a810e..408cfc850 100644 --- a/crates/neon/src/sys/tsfn.rs +++ b/crates/neon/src/sys/tsfn.rs @@ -129,13 +129,13 @@ impl ThreadsafeFunction { /// References a threadsafe function to prevent exiting the event loop until it has been dropped. (Default) /// Safety: `Env` must be valid for the current thread pub unsafe fn reference(&self, env: Env) { - let () = napi::ref_threadsafe_function(env, self.tsfn.0).unwrap(); + napi::ref_threadsafe_function(env, self.tsfn.0).unwrap(); } /// Unreferences a threadsafe function to allow exiting the event loop before it has been dropped. /// Safety: `Env` must be valid for the current thread pub unsafe fn unref(&self, env: Env) { - let () = napi::unref_threadsafe_function(env, self.tsfn.0).unwrap(); + napi::unref_threadsafe_function(env, self.tsfn.0).unwrap(); } // Provides a C ABI wrapper for a napi callback notifying us about tsfn diff --git a/crates/neon/src/sys/typedarray.rs b/crates/neon/src/sys/typedarray.rs index 7565ade42..f448af6e5 100644 --- a/crates/neon/src/sys/typedarray.rs +++ b/crates/neon/src/sys/typedarray.rs @@ -50,7 +50,7 @@ pub unsafe fn new( let mut array = MaybeUninit::uninit(); let status = napi::create_typedarray(env, typ, len, buffer, offset, array.as_mut_ptr()); - let () = match status { + match status { Err(err @ napi::Status::PendingException) => return Err(err), status => status.unwrap(), }; diff --git a/crates/neon/src/types_impl/bigint.rs b/crates/neon/src/types_impl/bigint.rs index 6d7d7d754..e4aa7bf09 100644 --- a/crates/neon/src/types_impl/bigint.rs +++ b/crates/neon/src/types_impl/bigint.rs @@ -76,7 +76,7 @@ impl JsBigInt { { let mut v = MaybeUninit::uninit(); let v = unsafe { - let () = sys::create_bigint_int64(cx.env().to_raw(), n, v.as_mut_ptr()).unwrap(); + sys::create_bigint_int64(cx.env().to_raw(), n, v.as_mut_ptr()).unwrap(); v.assume_init() }; @@ -101,7 +101,7 @@ impl JsBigInt { { let mut v = MaybeUninit::uninit(); let v = unsafe { - let () = sys::create_bigint_uint64(cx.env().to_raw(), n, v.as_mut_ptr()).unwrap(); + sys::create_bigint_uint64(cx.env().to_raw(), n, v.as_mut_ptr()).unwrap(); v.assume_init() }; @@ -196,7 +196,7 @@ impl JsBigInt { let mut v = MaybeUninit::uninit(); let v = unsafe { - let () = sys::create_bigint_words( + sys::create_bigint_words( cx.env().to_raw(), sign_bit, digits.len(), @@ -226,8 +226,7 @@ impl JsBigInt { let mut lossless = false; unsafe { - let () = sys::get_value_bigint_int64(cx.env().to_raw(), self.0, &mut n, &mut lossless) - .unwrap(); + sys::get_value_bigint_int64(cx.env().to_raw(), self.0, &mut n, &mut lossless).unwrap(); } if lossless { @@ -248,8 +247,7 @@ impl JsBigInt { let mut lossless = false; unsafe { - let () = sys::get_value_bigint_uint64(cx.env().to_raw(), self.0, &mut n, &mut lossless) - .unwrap(); + sys::get_value_bigint_uint64(cx.env().to_raw(), self.0, &mut n, &mut lossless).unwrap(); } if lossless { @@ -374,7 +372,7 @@ impl JsBigInt { let mut word_count = digits.len(); unsafe { - let () = sys::get_value_bigint_words( + sys::get_value_bigint_words( cx.env().to_raw(), self.0, &mut sign_bit, diff --git a/crates/neon/src/types_impl/extract/try_from_js.rs b/crates/neon/src/types_impl/extract/try_from_js.rs index 1b5e6d58b..8d0e65013 100644 --- a/crates/neon/src/types_impl/extract/try_from_js.rs +++ b/crates/neon/src/types_impl/extract/try_from_js.rs @@ -81,7 +81,7 @@ impl<'cx> TryFromJs<'cx> for f64 { let mut n = 0f64; unsafe { - let () = match sys::get_value_double(cx.env().to_raw(), v.to_local(), &mut n) { + match sys::get_value_double(cx.env().to_raw(), v.to_local(), &mut n) { Err(sys::Status::NumberExpected) => return Ok(Err(TypeExpected::new())), Err(sys::Status::PendingException) => return Err(Throw::new()), status => status.unwrap(), @@ -102,7 +102,7 @@ impl<'cx> TryFromJs<'cx> for bool { let mut b = false; unsafe { - let () = match sys::get_value_bool(cx.env().to_raw(), v.to_local(), &mut b) { + match sys::get_value_bool(cx.env().to_raw(), v.to_local(), &mut b) { Err(sys::Status::BooleanExpected) => return Ok(Err(TypeExpected::new())), Err(sys::Status::PendingException) => return Err(Throw::new()), status => status.unwrap(), @@ -125,7 +125,7 @@ impl<'cx> TryFromJs<'cx> for String { let mut len = 0usize; unsafe { - let () = match sys::get_value_string_utf8(env, v, ptr::null_mut(), 0, &mut len) { + match sys::get_value_string_utf8(env, v, ptr::null_mut(), 0, &mut len) { Err(sys::Status::StringExpected) => return Ok(Err(TypeExpected::new())), Err(sys::Status::PendingException) => return Err(Throw::new()), status => status.unwrap(), @@ -168,7 +168,7 @@ impl<'cx> TryFromJs<'cx> for Date { let mut d = 0f64; unsafe { - let () = match sys::get_date_value(cx.env().to_raw(), v.to_local(), &mut d) { + match sys::get_date_value(cx.env().to_raw(), v.to_local(), &mut d) { Err(sys::Status::DateExpected) => return Ok(Err(TypeExpected::new())), Err(sys::Status::PendingException) => return Err(Throw::new()), status => status.unwrap(), @@ -259,7 +259,7 @@ where let mut ty = sys::ValueType::Object; unsafe { - let () = match sys::typeof_value(cx.env().to_raw(), v.to_local(), &mut ty) { + match sys::typeof_value(cx.env().to_raw(), v.to_local(), &mut ty) { Err(sys::Status::PendingException) => return Err(Throw::new()), status => status.unwrap(), };