style: apply clippy suggestion

This commit is contained in:
LongYinan 2022-02-06 10:49:16 +08:00
parent 9f66ca2818
commit 89893cdca3
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
5 changed files with 6 additions and 6 deletions

View file

@ -76,7 +76,7 @@ fn escape_json(src: &str) -> String {
c => { c => {
let encoded = c.encode_utf16(&mut utf16_buf); let encoded = c.encode_utf16(&mut utf16_buf);
for utf16 in encoded { for utf16 in encoded {
write!(&mut escaped, "\\u{:04X}", utf16).unwrap(); write!(escaped, "\\u{:04X}", utf16).unwrap();
} }
} }
} }

View file

@ -6,7 +6,7 @@ use napi::{CallContext, JsArrayBuffer, JsNumber, JsObject, JsTypedArray, JsUndef
#[js_function(1)] #[js_function(1)]
pub fn get_arraybuffer_length(ctx: CallContext) -> Result<JsNumber> { pub fn get_arraybuffer_length(ctx: CallContext) -> Result<JsNumber> {
let buffer = ctx.get::<JsArrayBuffer>(0)?.into_value()?; let buffer = ctx.get::<JsArrayBuffer>(0)?.into_value()?;
ctx.env.create_uint32((&buffer).len() as u32) ctx.env.create_uint32(buffer.len() as u32)
} }
#[js_function(1)] #[js_function(1)]

View file

@ -9,7 +9,7 @@ use napi::{
#[js_function(1)] #[js_function(1)]
pub fn get_buffer_length(ctx: CallContext) -> Result<JsNumber> { pub fn get_buffer_length(ctx: CallContext) -> Result<JsNumber> {
let buffer = ctx.get::<JsBuffer>(0)?.into_value()?; let buffer = ctx.get::<JsBuffer>(0)?.into_value()?;
ctx.env.create_uint32((&buffer).len() as u32) ctx.env.create_uint32(buffer.len() as u32)
} }
#[js_function(1)] #[js_function(1)]

View file

@ -60,7 +60,7 @@ impl Task for CountBufferLength {
if self.data.len() == 10 { if self.data.len() == 10 {
return Err(Error::from_reason("len can't be 5".to_string())); 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<Self::JsValue> { fn resolve(&mut self, env: Env, output: Self::Output) -> Result<Self::JsValue> {

View file

@ -234,7 +234,7 @@ impl JsAsset {
#[napi(getter)] #[napi(getter)]
pub fn get_file_path(&self) -> u32 { pub fn get_file_path(&self) -> u32 {
return 1; 1
} }
} }
@ -277,7 +277,7 @@ impl Optional {
pub fn option_only(optional: Option<String>) -> String { pub fn option_only(optional: Option<String>) -> String {
match optional { match optional {
None => "".to_string(), None => "".to_string(),
Some(optional) => format!("{}", optional), Some(optional) => optional,
} }
} }
} }