From c365c15639dcc24b92480e2e32fcd82956294e79 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 25 Nov 2021 23:35:50 +0800 Subject: [PATCH] style: clippy fix --- crates/backend/src/codegen/fn.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/crates/backend/src/codegen/fn.rs b/crates/backend/src/codegen/fn.rs index 2e805d52..426a29a8 100644 --- a/crates/backend/src/codegen/fn.rs +++ b/crates/backend/src/codegen/fn.rs @@ -264,28 +264,24 @@ impl NapiFn { quote! { <#ty as napi::bindgen_prelude::ToNapiValue>::to_napi_value(env, #ret) } + } else if is_return_self { + quote! { #ret.map(|_| cb.this) } } else { - if is_return_self { - quote! { #ret.map(|_| cb.this) } - } else { - quote! { - match #ret { - Ok(value) => napi::bindgen_prelude::ToNapiValue::to_napi_value(env, value), - Err(err) => { - napi::bindgen_prelude::JsError::from(err).throw_into(env); - Ok(std::ptr::null_mut()) - }, - } + quote! { + match #ret { + Ok(value) => napi::bindgen_prelude::ToNapiValue::to_napi_value(env, value), + Err(err) => { + napi::bindgen_prelude::JsError::from(err).throw_into(env); + Ok(std::ptr::null_mut()) + }, } } } + } else if is_return_self { + quote! { Ok(cb.this) } } else { - if is_return_self { - quote! { Ok(cb.this) } - } else { - quote! { - <#ty as napi::bindgen_prelude::ToNapiValue>::to_napi_value(env, #ret) - } + quote! { + <#ty as napi::bindgen_prelude::ToNapiValue>::to_napi_value(env, #ret) } } } else {