From 32371b77aaef496a3f5243afe55e033b7685954f Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Wed, 20 Sep 2023 03:41:44 +0300 Subject: [PATCH] Change the `fold_attrs` attr parameter type to `&[Attribute]` --- crates/teloxide-macros/src/attr.rs | 7 ++++--- crates/teloxide-macros/src/command_attr.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/teloxide-macros/src/attr.rs b/crates/teloxide-macros/src/attr.rs index 64be81a0..cbcee8ac 100644 --- a/crates/teloxide-macros/src/attr.rs +++ b/crates/teloxide-macros/src/attr.rs @@ -8,20 +8,21 @@ use syn::{ }; pub(crate) fn fold_attrs( - attrs: impl Iterator, + attrs: &[Attribute], filter: fn(&Attribute) -> bool, parse: impl Fn(Attr) -> Result, init: A, f: impl Fn(A, R) -> Result, ) -> Result { attrs - .filter(filter) + .iter() + .filter(|&a| filter(a)) .flat_map(|attribute| { let Some(key) = attribute.path.get_ident().cloned() else { return vec![Err(compile_error_at("expected an ident", attribute.path.span()))] }; match (|input: ParseStream<'_>| Attrs::parse_with_key(input, key)) - .parse(attribute.tokens.into()) + .parse(attribute.tokens.clone().into()) { Ok(ok) => ok.0.into_iter().map(&parse).collect(), Err(err) => vec![Err(err.into())], diff --git a/crates/teloxide-macros/src/command_attr.rs b/crates/teloxide-macros/src/command_attr.rs index 3e7a6592..b9ce1727 100644 --- a/crates/teloxide-macros/src/command_attr.rs +++ b/crates/teloxide-macros/src/command_attr.rs @@ -56,7 +56,7 @@ impl CommandAttrs { use CommandAttrKind::*; fold_attrs( - attributes.iter().cloned(), + attributes, |attr| is_command_attribute(attr) || is_doc_comment(attr), CommandAttr::parse, Self {