diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-10 16:04:57 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-10 16:04:57 +0800 |
| commit | eebcdf6b163174ec1629d121264c0477652e3323 (patch) | |
| tree | f3b56721e4159fe4069a4524ce9d1a47c865019d /mingling_macros/src/derive | |
| parent | a9d5943939261e27e58bcf5cacbb618a0f63e999 (diff) | |
refactor(macros): clean up clippy lints and simplify code
Diffstat (limited to 'mingling_macros/src/derive')
| -rw-r--r-- | mingling_macros/src/derive/enum_tag.rs | 14 |
1 files changed, 4 insertions, 10 deletions
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<Option<String>> { for attr in attrs { if attr.path().is_ident("enum_desc") { - return match attr.parse_args::<LitStr>() { - Ok(lit_str) => Ok(Some(lit_str.value())), - Err(_) => Err(Error::new_spanned( + return attr.parse_args::<LitStr>().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<Option<String>> { fn extract_rename(attrs: &[Attribute]) -> Result<Option<String>> { for attr in attrs { if attr.path().is_ident("enum_rename") { - return match attr.parse_args::<LitStr>() { - Ok(lit_str) => Ok(Some(lit_str.value())), - Err(_) => Err(Error::new_spanned( + return attr.parse_args::<LitStr>().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()))); } } |
