Merge pull request #1063 from napi-rs/clippy-fix

style: apply clippy suggestion
This commit is contained in:
LongYinan 2022-02-06 11:02:02 +08:00 committed by GitHub
commit c001038852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View file

@ -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();
}
}
}

View file

@ -6,7 +6,7 @@ use napi::{CallContext, JsArrayBuffer, JsNumber, JsObject, JsTypedArray, JsUndef
#[js_function(1)]
pub fn get_arraybuffer_length(ctx: CallContext) -> Result<JsNumber> {
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)]

View file

@ -9,7 +9,7 @@ use napi::{
#[js_function(1)]
pub fn get_buffer_length(ctx: CallContext) -> Result<JsNumber> {
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)]

View file

@ -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<Self::JsValue> {

View file

@ -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>) -> String {
match optional {
None => "".to_string(),
Some(optional) => format!("{}", optional),
Some(optional) => optional,
}
}
}