From 89893cdca37ef485465b638c580f88e4cf764cc9 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 6 Feb 2022 10:49:16 +0800 Subject: [PATCH] style: apply clippy suggestion --- crates/backend/src/typegen.rs | 2 +- examples/napi-compat-mode/src/arraybuffer.rs | 2 +- examples/napi-compat-mode/src/buffer.rs | 2 +- examples/napi-compat-mode/src/task.rs | 2 +- examples/napi/src/class.rs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/backend/src/typegen.rs b/crates/backend/src/typegen.rs index c8417a1a..846ea47c 100644 --- a/crates/backend/src/typegen.rs +++ b/crates/backend/src/typegen.rs @@ -76,7 +76,7 @@ fn escape_json(src: &str) -> String { c => { let encoded = c.encode_utf16(&mut utf16_buf); for utf16 in encoded { - write!(&mut escaped, "\\u{:04X}", utf16).unwrap(); + write!(escaped, "\\u{:04X}", utf16).unwrap(); } } } diff --git a/examples/napi-compat-mode/src/arraybuffer.rs b/examples/napi-compat-mode/src/arraybuffer.rs index 2ce536c7..2227d467 100644 --- a/examples/napi-compat-mode/src/arraybuffer.rs +++ b/examples/napi-compat-mode/src/arraybuffer.rs @@ -6,7 +6,7 @@ use napi::{CallContext, JsArrayBuffer, JsNumber, JsObject, JsTypedArray, JsUndef #[js_function(1)] pub fn get_arraybuffer_length(ctx: CallContext) -> Result { let buffer = ctx.get::(0)?.into_value()?; - ctx.env.create_uint32((&buffer).len() as u32) + ctx.env.create_uint32(buffer.len() as u32) } #[js_function(1)] diff --git a/examples/napi-compat-mode/src/buffer.rs b/examples/napi-compat-mode/src/buffer.rs index 45628d07..24be7ded 100644 --- a/examples/napi-compat-mode/src/buffer.rs +++ b/examples/napi-compat-mode/src/buffer.rs @@ -9,7 +9,7 @@ use napi::{ #[js_function(1)] pub fn get_buffer_length(ctx: CallContext) -> Result { let buffer = ctx.get::(0)?.into_value()?; - ctx.env.create_uint32((&buffer).len() as u32) + ctx.env.create_uint32(buffer.len() as u32) } #[js_function(1)] diff --git a/examples/napi-compat-mode/src/task.rs b/examples/napi-compat-mode/src/task.rs index 52a688de..56d2352e 100644 --- a/examples/napi-compat-mode/src/task.rs +++ b/examples/napi-compat-mode/src/task.rs @@ -60,7 +60,7 @@ impl Task for CountBufferLength { if self.data.len() == 10 { return Err(Error::from_reason("len can't be 5".to_string())); } - Ok((&self.data).len()) + Ok(self.data.len()) } fn resolve(&mut self, env: Env, output: Self::Output) -> Result { diff --git a/examples/napi/src/class.rs b/examples/napi/src/class.rs index a59227ff..c909d627 100644 --- a/examples/napi/src/class.rs +++ b/examples/napi/src/class.rs @@ -234,7 +234,7 @@ impl JsAsset { #[napi(getter)] pub fn get_file_path(&self) -> u32 { - return 1; + 1 } } @@ -277,7 +277,7 @@ impl Optional { pub fn option_only(optional: Option) -> String { match optional { None => "".to_string(), - Some(optional) => format!("{}", optional), + Some(optional) => optional, } } }