MCPcopy Create free account
hub / github.com/Wulf/tsync / tsync

Function tsync

tsync-macro/src/lib.rs:7–32  ·  view source on GitHub ↗
(_attr: TokenStream, item: TokenStream)

Source from the content-addressed store, hash-verified

5// document this attribute
6#[proc_macro_attribute]
7pub 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected