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/func/suggest.rs | |
| parent | a9d5943939261e27e58bcf5cacbb618a0f63e999 (diff) | |
refactor(macros): clean up clippy lints and simplify code
Diffstat (limited to 'mingling_macros/src/func/suggest.rs')
| -rw-r--r-- | mingling_macros/src/func/suggest.rs | 9 |
1 files changed, 4 insertions, 5 deletions
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<Self> { 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(_))) } |
