1pub trait Attrs {
5 #[must_use]
7 fn attrs(&self) -> &[syn::Attribute];
8}
9
10impl Attrs for Vec<syn::Attribute> {
11 fn attrs(&self) -> &[syn::Attribute] {
12 self
13 }
14}
15
16macro_rules! impl_attrs_for {
18 ($( $ty:ty, )+) => {$(
19 impl Attrs for $ty {
20 fn attrs(&self) -> &[syn::Attribute] {
21 &*self.attrs
22 }
23 }
24 )+}
25}
26
27impl_attrs_for! {
28 syn::BareFnArg,
29 syn::ConstParam,
30 syn::DeriveInput,
31 syn::Field,
32 syn::LifetimeParam,
33 syn::TypeParam,
34 syn::Variant,
35}
36
37#[cfg(feature = "full")]
38macro_rules! impl_attrs_full_for {
41 ($( $ty:ty, )+) => {$(
42 #[cfg(feature = "full")]
43 impl Attrs for $ty {
44 fn attrs(&self) -> &[syn::Attribute] {
45 &*self.attrs
46 }
47 }
48 )+}
49}
50
51#[cfg(feature = "full")]
52impl_attrs_full_for! {
53 syn::Arm,
54 syn::ExprArray,
55 syn::ExprAssign,
56 syn::ExprAsync,
57 syn::ExprAwait,
58 syn::ExprBinary,
59 syn::ExprBlock,
60 syn::ExprBreak,
61 syn::ExprCall,
62 syn::ExprCast,
63 syn::ExprClosure,
64 syn::ExprContinue,
65 syn::ExprField,
66 syn::ExprForLoop,
67 syn::ExprGroup,
68 syn::ExprIf,
69 syn::ExprIndex,
70 syn::ExprLet,
71 syn::ExprLit,
72 syn::ExprLoop,
73 syn::ExprMacro,
74 syn::ExprMatch,
75 syn::ExprMethodCall,
76 syn::ExprParen,
77 syn::ExprPath,
78 syn::ExprRange,
79 syn::ExprReference,
80 syn::ExprRepeat,
81 syn::ExprReturn,
82 syn::ExprStruct,
83 syn::ExprTry,
84 syn::ExprTryBlock,
85 syn::ExprTuple,
86 syn::ExprUnary,
87 syn::ExprUnsafe,
88 syn::ExprWhile,
89 syn::ExprYield,
90 syn::FieldPat,
91 syn::FieldValue,
92 syn::File,
93 syn::ForeignItemFn,
94 syn::ForeignItemMacro,
95 syn::ForeignItemStatic,
96 syn::ForeignItemType,
97 syn::ImplItemConst,
98 syn::ImplItemFn,
99 syn::ImplItemMacro,
100 syn::ImplItemType,
101 syn::ItemConst,
102 syn::ItemEnum,
103 syn::ItemExternCrate,
104 syn::ItemFn,
105 syn::ItemForeignMod,
106 syn::ItemImpl,
107 syn::ItemMacro,
108 syn::ItemMod,
109 syn::ItemStatic,
110 syn::ItemStruct,
111 syn::ItemTrait,
112 syn::ItemTraitAlias,
113 syn::ItemType,
114 syn::ItemUnion,
115 syn::ItemUse,
116 syn::Local,
117 syn::PatIdent,
118 syn::PatOr,
119 syn::PatReference,
120 syn::PatRest,
121 syn::PatSlice,
122 syn::PatStruct,
123 syn::PatTuple,
124 syn::PatTupleStruct,
125 syn::PatType,
126 syn::PatWild,
127 syn::Receiver,
128 syn::TraitItemConst,
129 syn::TraitItemFn,
130 syn::TraitItemMacro,
131 syn::TraitItemType,
132}