From 15ccd864c8869f87a564e5ab7e923dcc2bb54340 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 31 Oct 2021 21:31:04 +0530 Subject: add explainations to each lint --- macros/src/explain.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'macros') diff --git a/macros/src/explain.rs b/macros/src/explain.rs index 8b00740..9bc3c29 100644 --- a/macros/src/explain.rs +++ b/macros/src/explain.rs @@ -7,15 +7,15 @@ pub fn generate_explain_impl(struct_item: &ItemStruct) -> TokenStream2 { let explain = struct_item .attrs .iter() - .filter_map(|a| a.parse_meta().ok()) - .filter_map(|meta| match meta { - Meta::NameValue(MetaNameValue { path, lit, .. }) if path.is_ident("doc") => Some(lit), - _ => None, - }) - .filter_map(|lit| match lit { - Lit::Str(str_lit) => Some(str_lit.value()), + .filter_map(|attr| match attr.parse_meta().ok() { + Some(Meta::NameValue(MetaNameValue { + path, + lit: Lit::Str(str_lit), + .. + })) if path.is_ident("doc") => Some(str_lit.value()), _ => None, }) + .map(|s| s.strip_prefix(' ').unwrap_or(&s).to_owned()) .collect::>() .join("\n"); quote! { -- cgit v1.2.3