(_attr: TokenStream, item: TokenStream)
| 5 | // document this attribute |
| 6 | #[proc_macro_attribute] |
| 7 | pub fn tsync(_attr: TokenStream, item: TokenStream) -> TokenStream { |
| 8 | let mut input = parse_macro_input!(item as DeriveInput); |
| 9 | |
| 10 | // Remove tsync decorators from struct fields |
| 11 | if let syn::Data::Struct(ref mut data) = input.data { |
| 12 | if let syn::Fields::Named(ref mut fields) = data.fields { |
| 13 | for field in fields.named.iter_mut() { |
| 14 | // Remove all tsync attributes |
| 15 | field.attrs.retain(|attr| !attr.path().is_ident("tsync")); |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | if let syn::Data::Enum(ref mut data) = input.data { |
| 21 | for variant in data.variants.iter_mut() { |
| 22 | // Remove all tsync attributes |
| 23 | variant.attrs.retain(|attr| !attr.path().is_ident("tsync")); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // Return the struct without the field-level tsync attributes |
| 28 | quote! { |
| 29 | #input |
| 30 | } |
| 31 | .into() |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected