Simplify creating and using doc_attributes vec

This commit is contained in:
Erik Johnston 2021-02-24 11:55:17 +00:00
parent 16d21906df
commit 99a1db806c
1 changed files with 8 additions and 14 deletions

View File

@ -229,13 +229,12 @@ impl Route {
// //
// Note that multi line doc comments are converted to multiple doc // Note that multi line doc comments are converted to multiple doc
// attributes. // attributes.
let mut doc_attributes = Vec::new(); let doc_attributes = ast
for attr in &ast.attrs { .attrs
if attr.path.get_ident().is_ident("doc") { .iter()
doc_attribute.push(attr.clone()); .filter(|attr| attr.path.is_ident("doc"))
} .cloned()
} .collect();
}
let args = Args::new(args, method)?; let args = Args::new(args, method)?;
if args.methods.is_empty() { if args.methods.is_empty() {
@ -264,7 +263,7 @@ impl Route {
args, args,
ast, ast,
resource_type, resource_type,
doc_attributes: doc_attribute, doc_attributes,
}) })
} }
} }
@ -304,13 +303,8 @@ impl ToTokens for Route {
} }
}; };
let doc_comment_token_stream: TokenStream2 = doc_attribute
.iter()
.map(ToTokens::to_token_stream)
.collect();
let stream = quote! { let stream = quote! {
#(#doc_comments)* #(#doc_attributes)*
#[allow(non_camel_case_types, missing_docs)] #[allow(non_camel_case_types, missing_docs)]
pub struct #name; pub struct #name;