Make attrs in fold_attrs expect Iterator of Attribute instead of &[Attribute]

This commit is contained in:
TheAwiteb 2023-03-02 15:04:59 +03:00
parent 9b7e5957cc
commit 47ad84c17e
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34

View file

@ -7,15 +7,14 @@ use syn::{
Attribute, Ident, Lit, Path, Token, Attribute, Ident, Lit, Path, Token,
}; };
pub(crate) fn fold_attrs<A, R>( pub(crate) fn fold_attrs<'a, A, R>(
attrs: &[Attribute], attrs: impl Iterator<Item = &'a Attribute>,
filter: fn(&Attribute) -> bool, filter: fn(&Attribute) -> bool,
parse: impl Fn(Attr) -> Result<R>, parse: impl Fn(Attr) -> Result<R>,
init: A, init: A,
f: impl Fn(A, R) -> Result<A>, f: impl Fn(A, R) -> Result<A>,
) -> Result<A> { ) -> Result<A> {
attrs attrs
.iter()
.filter(|&a| filter(a)) .filter(|&a| filter(a))
.flat_map(|attribute| { .flat_map(|attribute| {
// FIXME: don't allocate here // FIXME: don't allocate here