From eebcdf6b163174ec1629d121264c0477652e3323 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 10 Aug 2026 16:04:57 +0800 Subject: refactor(macros): clean up clippy lints and simplify code --- mingling_macros/src/derive/enum_tag.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'mingling_macros/src/derive') diff --git a/mingling_macros/src/derive/enum_tag.rs b/mingling_macros/src/derive/enum_tag.rs index a7f71f0..fb1710f 100644 --- a/mingling_macros/src/derive/enum_tag.rs +++ b/mingling_macros/src/derive/enum_tag.rs @@ -135,13 +135,10 @@ fn process_variant( fn extract_description(attrs: &[Attribute]) -> Result> { for attr in attrs { if attr.path().is_ident("enum_desc") { - return match attr.parse_args::() { - Ok(lit_str) => Ok(Some(lit_str.value())), - Err(_) => Err(Error::new_spanned( + return attr.parse_args::().map_or_else(|_| Err(Error::new_spanned( attr, "#[enum_desc] attribute must be in the form `#[enum_desc(\"description\")]`", - )), - }; + )), |lit_str| Ok(Some(lit_str.value()))); } } @@ -153,13 +150,10 @@ fn extract_description(attrs: &[Attribute]) -> Result> { fn extract_rename(attrs: &[Attribute]) -> Result> { for attr in attrs { if attr.path().is_ident("enum_rename") { - return match attr.parse_args::() { - Ok(lit_str) => Ok(Some(lit_str.value())), - Err(_) => Err(Error::new_spanned( + return attr.parse_args::().map_or_else(|_| Err(Error::new_spanned( attr, "#[enum_rename] attribute must be in the form `#[enum_rename(\"new_name\")]`", - )), - }; + )), |lit_str| Ok(Some(lit_str.value()))); } } -- cgit