mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Change the fold_attrs
attr parameter type to &[Attribute]
This commit is contained in:
parent
c50513b6e4
commit
32371b77aa
2 changed files with 5 additions and 4 deletions
|
@ -8,20 +8,21 @@ use syn::{
|
|||
};
|
||||
|
||||
pub(crate) fn fold_attrs<A, R>(
|
||||
attrs: impl Iterator<Item = Attribute>,
|
||||
attrs: &[Attribute],
|
||||
filter: fn(&Attribute) -> bool,
|
||||
parse: impl Fn(Attr) -> Result<R>,
|
||||
init: A,
|
||||
f: impl Fn(A, R) -> Result<A>,
|
||||
) -> Result<A> {
|
||||
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())],
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue