enum_dispatch/
filter_attrs.rs

1//! Convenience traits for splitting inner and outer attributes. These were originally private to
2//! the syn crate.
3
4/// Private trait copied from syn::attr.rs for convenience when implementing ToTokens
5pub trait FilterAttrs<'a> {
6    type Ret: Iterator<Item = &'a syn::Attribute>;
7
8    fn outer(self) -> Self::Ret;
9}
10
11/// Private trait impl copied from syn::attr.rs for convenience when implementing ToTokens
12impl<'a, T> FilterAttrs<'a> for T
13where
14    T: IntoIterator<Item = &'a syn::Attribute>,
15{
16    type Ret = ::std::iter::Filter<T::IntoIter, fn(&&syn::Attribute) -> bool>;
17
18    fn outer(self) -> Self::Ret {
19        fn is_outer(attr: &&syn::Attribute) -> bool {
20            matches!(attr.style, syn::AttrStyle::Outer)
21        }
22        self.into_iter().filter(is_outer)
23    }
24}