fix(napi): apply clippy suggestions (#1878)

This commit is contained in:
LongYinan 2023-12-29 23:08:56 +08:00 committed by GitHub
parent 958ba74aff
commit 43a080d52b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View file

@ -396,7 +396,10 @@ pub unsafe extern "C" fn napi_register_module_v1(
}
let (ctor, props): (Vec<_>, Vec<_>) = props.iter().partition(|prop| prop.is_ctor);
let ctor = ctor.get(0).map(|c| c.raw().method.unwrap()).unwrap_or(noop);
let ctor = ctor
.first()
.map(|c| c.raw().method.unwrap())
.unwrap_or(noop);
let raw_props: Vec<_> = props.iter().map(|prop| prop.raw()).collect();
let js_class_name = CStr::from_bytes_with_nul_unchecked(js_name.as_bytes());

View file

@ -1567,7 +1567,7 @@ pub(crate) unsafe extern "C" fn trampoline_setter<
let closure: &F = Box::leak(unsafe { Box::from_raw(closure_data_ptr.cast()) });
let env = unsafe { Env::from_raw(raw_env) };
raw_args
.get(0)
.first()
.ok_or_else(|| Error::new(Status::InvalidArg, "Missing argument in property setter"))
.and_then(|value| unsafe { V::from_napi_value(raw_env, *value) })
.and_then(|value| {

View file

@ -2,6 +2,7 @@
#![allow(unreachable_code)]
#![allow(clippy::disallowed_names)]
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::new_without_default)]
#[macro_use]
extern crate napi_derive;