From 77e4241b18911ddfb0a9a67a39f33a6f6a9b5a59 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 2 Dec 2021 16:31:57 +0800 Subject: [PATCH] style: clippy fix --- crates/backend/src/codegen/struct.rs | 2 +- crates/backend/src/typegen.rs | 2 +- examples/napi/src/object.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/backend/src/codegen/struct.rs b/crates/backend/src/codegen/struct.rs index 07718f4a..655d6ab5 100644 --- a/crates/backend/src/codegen/struct.rs +++ b/crates/backend/src/codegen/struct.rs @@ -245,7 +245,7 @@ impl NapiStruct { }) = &ty { if let Some(last_path) = segments.last() { - last_path.ident.to_string() == "Option" + last_path.ident == "Option" } else { false } diff --git a/crates/backend/src/typegen.rs b/crates/backend/src/typegen.rs index e606fd09..8076e4b9 100644 --- a/crates/backend/src/typegen.rs +++ b/crates/backend/src/typegen.rs @@ -264,7 +264,7 @@ pub fn ty_to_ts_type(ty: &Type, is_return_ty: bool) -> (String, bool) { .get(rust_ty.as_str()) .map(|a| (a.to_owned(), false)) }); - ts_ty = type_alias.or_else(|| Some((rust_ty, false))); + ts_ty = type_alias.or(Some((rust_ty, false))); } } diff --git a/examples/napi/src/object.rs b/examples/napi/src/object.rs index 6faeca0c..741c74cf 100644 --- a/examples/napi/src/object.rs +++ b/examples/napi/src/object.rs @@ -36,7 +36,7 @@ struct AllOptionalObject { #[napi] fn receive_all_optional_object(obj: Option) -> Result<()> { - if !obj.is_none() { + if obj.is_some() { assert!(obj.as_ref().unwrap().name.is_none()); assert!(obj.as_ref().unwrap().age.is_none()); }