Merge pull request #1063 from napi-rs/clippy-fix
style: apply clippy suggestion
This commit is contained in:
commit
c001038852
5 changed files with 6 additions and 6 deletions
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)]
|
||||||
|
|
|
@ -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)]
|
||||||
|
|
|
@ -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> {
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue