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/func/suggest.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'mingling_macros/src/func/suggest.rs') diff --git a/mingling_macros/src/func/suggest.rs b/mingling_macros/src/func/suggest.rs index 6613a98..c2841d5 100644 --- a/mingling_macros/src/func/suggest.rs +++ b/mingling_macros/src/func/suggest.rs @@ -16,7 +16,7 @@ enum SuggestItem { impl Parse for SuggestInput { fn parse(input: ParseStream) -> syn::Result { let items = Punctuated::parse_terminated(input)?; - Ok(SuggestInput { items }) + Ok(Self { items }) } } @@ -27,15 +27,14 @@ impl Parse for SuggestItem { if input.peek(Token![:]) { let _colon: Token![:] = input.parse()?; let value: Expr = input.parse()?; - Ok(SuggestItem::WithDesc(Box::new((key, value)))) + Ok(Self::WithDesc(Box::new((key, value)))) } else { - Ok(SuggestItem::Simple(key)) + Ok(Self::Simple(key)) } } } -/// 判断表达式是否是一个纯字符串字面量(仅由一对引号包裹) -fn is_pure_lit_str(expr: &Expr) -> bool { +const fn is_pure_lit_str(expr: &Expr) -> bool { matches!(expr, Expr::Lit(lit) if matches!(lit.lit, syn::Lit::Str(_))) } -- cgit