From a5d9e317273471c4d96415a4879dde7d9b0c0425 Mon Sep 17 00:00:00 2001 From: Alice Ferrazzi Date: Thu, 29 Sep 2022 15:01:16 +0900 Subject: [PATCH] macros: error: use `type` definitions for reduce complexity fix clippy error: very complex type used. Consider factoring parts into `type` definitions Signed-off-by: Alice Ferrazzi Reviewed-by: Luca Barbato --- rust/macros/helpers.rs | 2 ++ rust/macros/module.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/macros/helpers.rs b/rust/macros/helpers.rs index 8b5f9bc414d7ae..5ae30b52d8b2fe 100644 --- a/rust/macros/helpers.rs +++ b/rust/macros/helpers.rs @@ -2,6 +2,8 @@ use proc_macro::{token_stream, Group, TokenTree}; +pub(crate) type FnTrySimpleParam = Box Option>; + pub(crate) fn try_ident(it: &mut token_stream::IntoIter) -> Option { if let Some(TokenTree::Ident(ident)) = it.next() { Some(ident.to_string()) diff --git a/rust/macros/module.rs b/rust/macros/module.rs index 6001fd692469be..1fc532061a69d3 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -145,7 +145,7 @@ fn param_ops_path(param_type: &str) -> &'static str { fn try_simple_param_val( param_type: &str, -) -> Box Option> { +) -> FnTrySimpleParam { match param_type { "bool" => Box::new(try_ident), "str" => Box::new(|param_it| {