style: clippy fix (#1711)
This commit is contained in:
parent
fda46658f4
commit
05b4be4d80
10 changed files with 11 additions and 10 deletions
|
@ -918,8 +918,8 @@ impl NapiImpl {
|
|||
}
|
||||
|
||||
fn rm_raw_prefix(s: &str) -> &str {
|
||||
if s.starts_with("r#") {
|
||||
&s[2..]
|
||||
if let Some(stripped) = s.strip_prefix("r#") {
|
||||
stripped
|
||||
} else {
|
||||
s
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ impl ToTypeDef for NapiFn {
|
|||
.ts_generic_types
|
||||
.as_ref()
|
||||
.map(|g| format!("<{}>", g))
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
.unwrap_or_default(),
|
||||
args = self
|
||||
.ts_args_type
|
||||
.clone()
|
||||
|
|
|
@ -210,7 +210,7 @@ pub unsafe extern "C" fn symbol_generator<T: Generator>(
|
|||
"Create generator state failed"
|
||||
);
|
||||
|
||||
let properties = vec![sys::napi_property_descriptor {
|
||||
let properties = [sys::napi_property_descriptor {
|
||||
utf8name: GENERATOR_STATE_KEY.as_ptr().cast(),
|
||||
name: ptr::null_mut(),
|
||||
method: None,
|
||||
|
|
|
@ -402,7 +402,6 @@ unsafe extern "C" fn finalizer<Data, T: Finalizer<RustType = Data>>(
|
|||
}
|
||||
DataManagedType::Owned => {
|
||||
if data.ref_count() == 1 {
|
||||
let length = length;
|
||||
unsafe { Vec::from_raw_parts(finalize_data as *mut Data, length, length) };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,6 @@ impl FromNapiValue for DateTime<Utc> {
|
|||
(milliseconds_since_epoch_utc % 1_000 * 1_000_000) as u32,
|
||||
)
|
||||
.ok_or_else(|| Error::new(Status::DateExpected, "Found invalid date".to_owned()))?;
|
||||
Ok(DateTime::<Utc>::from_utc(naive, Utc))
|
||||
Ok(DateTime::<Utc>::from_naive_utc_and_offset(naive, Utc))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ impl<T: 'static> Reference<T> {
|
|||
let s_ptr = Box::into_raw(Box::new(s));
|
||||
let prev_drop_fn = unsafe { Box::from_raw(self.finalize_callbacks.get()) };
|
||||
let drop_fn = Box::new(move || {
|
||||
unsafe { Box::from_raw(s_ptr) };
|
||||
drop(unsafe { Box::from_raw(s_ptr) });
|
||||
prev_drop_fn();
|
||||
});
|
||||
self.finalize_callbacks.set(Box::into_raw(drop_fn));
|
||||
|
|
|
@ -242,7 +242,7 @@ pub fn register_class(
|
|||
let val = inner.entry(rust_name).or_default();
|
||||
let val = val.entry(js_mod).or_default();
|
||||
val.0 = js_name;
|
||||
val.1.extend(props.into_iter());
|
||||
val.1.extend(props);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -740,6 +740,7 @@ impl Env {
|
|||
Ok(unsafe { JsFunction::from_raw_unchecked(self.0, raw_result) })
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_pass_by_ref_mut)]
|
||||
pub fn wrap<T: 'static>(&self, js_object: &mut JsObject, native_object: T) -> Result<()> {
|
||||
check_status!(unsafe {
|
||||
sys::napi_wrap(
|
||||
|
@ -813,7 +814,7 @@ impl Env {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn drop_wrapped<T: 'static>(&self, js_object: &mut JsObject) -> Result<()> {
|
||||
pub fn drop_wrapped<T: 'static>(&self, js_object: &JsObject) -> Result<()> {
|
||||
unsafe {
|
||||
let mut unknown_tagged_object = ptr::null_mut();
|
||||
check_status!(sys::napi_remove_wrap(
|
||||
|
|
|
@ -136,6 +136,7 @@ impl ThreadsafeFunctionHandle {
|
|||
f(aborted_guard)
|
||||
}
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
fn null() -> Arc<Self> {
|
||||
Self::new(null_mut())
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ fn add_native_count(ctx: CallContext) -> Result<JsNumber> {
|
|||
#[js_function]
|
||||
fn renew_wrapped(ctx: CallContext) -> Result<JsUndefined> {
|
||||
let mut this: JsObject = ctx.this_unchecked();
|
||||
ctx.env.drop_wrapped::<NativeClass>(&mut this)?;
|
||||
ctx.env.drop_wrapped::<NativeClass>(&this)?;
|
||||
ctx.env.wrap(&mut this, NativeClass { value: 42 })?;
|
||||
ctx.env.get_undefined()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue