1use unsynn::*;
4
5pub type VerbatimUntil<C> = Many<Cons<Except<C>, AngleTokenTree>>;
7
8keyword! {
9 pub KPath = "path";
11 pub KName = "name";
13 pub KCfgAttr = "cfg_attr";
15 pub KFn = "fn";
17 pub KPub = "pub";
19 pub KAsync = "async";
21 pub KUnsafe = "unsafe";
23 pub KExtern = "extern";
25 pub KConst = "const";
27 pub KWhere = "where";
29 pub KImpl = "impl";
31 pub KFor = "for";
33 pub KMod = "mod";
35 pub KTrait = "trait";
37 pub KCrate = "crate";
39 pub KSuper = "super";
41 pub KSelf = "self";
43 pub KMut = "mut";
45 pub KEnum = "enum";
47 pub KStruct = "struct";
49 pub KType = "type";
51 pub KStatic = "static";
53}
54
55operator! {
56 pub Eq = "=";
58 pub And = "&";
60}
61
62unsynn! {
63 #[derive(Clone)]
65 pub struct AngleTokenTree(
66 pub Either<Cons<Lt, Vec<Cons<Except<Gt>, AngleTokenTree>>, Gt>, TokenTree>,
67 );
68
69 pub struct SyncDocInner {
71 pub args: Option<CommaDelimitedVec<SyncDocArg>>,
73 }
74
75 pub enum SyncDocArg {
77 Path(PathArg),
79 Name(NameArg),
81 CfgAttr(CfgAttrArg),
83 }
84
85 pub struct PathArg {
87 pub _path: KPath,
88 pub _eq: Eq,
89 pub value: LiteralString,
90 }
91
92 pub struct NameArg {
94 pub _name: KName,
95 pub _eq: Eq,
96 pub value: LiteralString,
97 }
98
99 pub struct CfgAttrArg {
101 pub _cfg_attr: KCfgAttr,
102 pub _eq: Eq,
103 pub value: LiteralString,
104 }
105
106 #[derive(Clone)]
108 pub struct FnSig {
109 pub attributes: Option<Many<Attribute>>,
111 pub visibility: Option<Visibility>,
113 pub const_kw: Option<KConst>,
115 pub async_kw: Option<KAsync>,
117 pub unsafe_kw: Option<KUnsafe>,
119 pub extern_kw: Option<ExternSpec>,
121 pub _fn: KFn,
123 pub name: Ident,
125 pub generics: Option<Generics>,
127 pub params: ParenthesisGroupContaining<Option<CommaDelimitedVec<FnParam>>>,
129 pub return_type: Option<ReturnTypeFn>,
131 pub where_clause: Option<WhereClauses>,
133 pub body: BraceGroup,
134 }
135
136 #[derive(Clone)]
138 pub struct Attribute {
139 pub _hash: Pound,
141 pub content: BracketGroup,
143 }
144
145 #[derive(Clone)]
147 pub struct InnerAttribute {
148 pub _hash: Pound,
150 pub _bang: Bang,
152 pub content: BracketGroup,
154 }
155
156 pub enum AnyAttribute {
158 Inner(InnerAttribute),
159 Outer(Attribute),
160 }
161
162 #[derive(Clone)]
164 pub enum ExternSpec {
165 WithAbi(ExternWithAbi),
167 Bare(KExtern),
169 }
170
171 #[derive(Clone)]
173 pub struct ExternWithAbi {
174 pub _extern: KExtern,
176 pub abi: LiteralString,
178 }
179
180 #[derive(Clone)]
182 pub enum Visibility {
183 Restricted(RestrictedVis),
185 Public(KPub),
187 }
188
189 #[derive(Clone)]
191 pub struct RestrictedVis {
192 pub _pub: KPub,
194 pub restriction: ParenthesisGroup,
196 }
197
198 #[derive(Clone)]
200 pub struct Generics {
201 pub _lt: Lt,
203 pub content: Many<Cons<Except<Gt>, TokenTree>>,
205 pub _gt: Gt,
207 }
208
209 #[derive(Clone)]
211 pub struct ReturnTypeTrait {
212 pub _arrow: RArrow,
214 pub return_type: VerbatimUntil<Either<BraceGroup, Semicolon>>,
216 }
217
218 #[derive(Clone)]
220 pub struct ReturnTypeFn {
221 pub _arrow: RArrow,
223 pub return_type: VerbatimUntil<BraceGroup>,
225 }
226
227 #[derive(Clone)]
229 pub struct WhereClause {
230 pub _pred: VerbatimUntil<Colon>,
232 pub _colon: Colon,
234 pub bounds: VerbatimUntil<Either<Comma, Semicolon, BraceGroup>>,
236 }
237
238 #[derive(Clone)]
240 pub struct WhereClauses {
241 pub _kw_where: KWhere,
243 pub clauses: CommaDelimitedVec<WhereClausePredicate>,
245 }
246
247 #[derive(Clone)]
249 pub struct WhereClausePredicate {
250 pub pred: VerbatimUntil<Colon>,
252 pub _colon: Colon,
254 pub bounds: VerbatimUntil<Either<Comma, BraceGroup>>,
256 }
257
258 #[derive(Clone)]
260 pub enum ModuleItem {
261 TraitMethod(TraitMethodSig),
263 Function(FnSig),
265 ImplBlock(ImplBlockSig),
267 Module(ModuleSig),
269 Trait(TraitSig),
271 Enum(EnumSig),
273 Struct(StructSig),
275 TypeAlias(TypeAliasSig),
277 Const(ConstSig),
279 Static(StaticSig),
281 Other(TokenTree),
283 }
284
285 #[derive(Clone)]
287 pub struct ImplBlockSig {
288 pub attributes: Option<Many<Attribute>>,
290 pub _impl: KImpl,
292 pub generics: Option<Generics>,
294 pub target_type: Many<Cons<Except<Either<KFor, BraceGroup>>, TokenTree>>,
296 pub for_trait: Option<Cons<KFor, Many<Cons<Except<BraceGroup>, TokenTree>>>>,
298 pub where_clause: Option<WhereClauses>,
300 pub items: BraceGroupContaining<ModuleContent>,
302 }
303
304 #[derive(Clone)]
306 pub struct ModuleSig {
307 pub attributes: Option<Many<Attribute>>,
309 pub visibility: Option<Visibility>,
311 pub _mod: KMod,
313 pub name: Ident,
315 pub items: BraceGroupContaining<ModuleContent>,
317 }
318
319 #[derive(Clone)]
321 pub struct TraitSig {
322 pub attributes: Option<Many<Attribute>>,
324 pub visibility: Option<Visibility>,
326 pub unsafe_kw: Option<KUnsafe>,
328 pub _trait: KTrait,
330 pub name: Ident,
332 pub generics: Option<Generics>,
334 pub bounds: Option<Cons<Colon, Many<Cons<Except<Either<KWhere, BraceGroup>>, TokenTree>>>>,
336 pub where_clause: Option<WhereClauses>,
338 pub items: BraceGroupContaining<ModuleContent>,
340 }
341
342 #[derive(Clone)]
344 pub struct TraitMethodSig {
345 pub attributes: Option<Many<Attribute>>,
347 pub const_kw: Option<KConst>,
349 pub async_kw: Option<KAsync>,
351 pub unsafe_kw: Option<KUnsafe>,
353 pub extern_kw: Option<ExternSpec>,
355 pub _fn: KFn,
357 pub name: Ident,
359 pub generics: Option<Generics>,
361 pub params: ParenthesisGroupContaining<Option<CommaDelimitedVec<FnParam>>>,
363 pub return_type: Option<ReturnTypeTrait>,
365 pub where_clause: Option<WhereClauses>,
367 pub _semi: Semicolon,
369 }
370
371 #[derive(Clone)]
373 pub struct EnumSig {
374 pub attributes: Option<Many<Attribute>>,
376 pub visibility: Option<Visibility>,
378 pub _enum: KEnum,
380 pub name: Ident,
382 pub generics: Option<Generics>,
384 pub where_clause: Option<WhereClauses>,
386 pub variants: BraceGroupContaining<Option<CommaDelimitedVec<EnumVariant>>>,
388 }
389
390 #[derive(Clone)]
392 pub struct StructSig {
393 pub attributes: Option<Many<Attribute>>,
395 pub visibility: Option<Visibility>,
397 pub _struct: KStruct,
399 pub name: Ident,
401 pub generics: Option<Generics>,
403 pub where_clause: Option<WhereClauses>,
405 pub body: StructBody,
407 }
408
409 #[derive(Clone)]
411 pub enum StructBody {
412 Named(BraceGroupContaining<Option<CommaDelimitedVec<StructField>>>),
414 Tuple(Cons<ParenthesisGroup, Semicolon>),
416 Unit(Semicolon),
418 }
419
420 #[derive(Clone)]
422 pub struct StructField {
423 pub attributes: Option<Many<Attribute>>,
425 pub visibility: Option<Visibility>,
427 pub name: Ident,
429 pub _colon: Colon,
431 pub field_type: VerbatimUntil<Either<Comma, BraceGroup>>,
433 }
434
435 #[derive(Clone)]
437 pub struct TypeAliasSig {
438 pub attributes: Option<Many<Attribute>>,
440 pub visibility: Option<Visibility>,
442 pub _type: KType,
444 pub name: Ident,
446 pub generics: Option<Generics>,
448 pub _eq: Eq,
450 pub target: VerbatimUntil<Semicolon>,
452 pub _semi: Semicolon,
454 }
455
456 #[derive(Clone)]
458 pub struct ConstSig {
459 pub attributes: Option<Many<Attribute>>,
461 pub visibility: Option<Visibility>,
463 pub _const: KConst,
465 pub name: Ident,
467 pub _colon: Colon,
469 pub const_type: VerbatimUntil<Eq>,
471 pub _eq: Eq,
473 pub value: VerbatimUntil<Semicolon>,
475 pub _semi: Semicolon,
477 }
478
479 #[derive(Clone)]
481 pub struct StaticSig {
482 pub attributes: Option<Many<Attribute>>,
484 pub visibility: Option<Visibility>,
486 pub _static: KStatic,
488 pub mut_kw: Option<KMut>,
490 pub name: Ident,
492 pub _colon: Colon,
494 pub static_type: VerbatimUntil<Eq>,
496 pub _eq: Eq,
498 pub value: VerbatimUntil<Semicolon>,
500 pub _semi: Semicolon,
502 }
503
504 #[derive(Clone)]
506 pub struct EnumVariant {
507 pub attributes: Option<Many<Attribute>>,
509 pub name: Ident,
511 pub data: Option<EnumVariantData>,
513 }
514
515 #[derive(Clone)]
517 pub enum EnumVariantData {
518 Tuple(ParenthesisGroup),
520 Struct(BraceGroupContaining<Option<CommaDelimitedVec<StructField>>>),
522 Discriminant(Cons<Eq, VerbatimUntil<Either<Comma, BraceGroup>>>),
524 }
525
526 #[derive(Clone)]
528 pub struct ModuleContent {
529 pub inner_attrs: Option<Many<InnerAttribute>>,
531 pub items: Many<ModuleItem>,
533 }
534
535 #[derive(Clone)]
537 pub enum FnParam {
538 SelfParam(SelfParam),
540 Named(NamedParam),
542 Pattern(PatternParam),
544 }
545
546 #[derive(Clone)]
548 pub enum SelfParam {
549 Value(KSelf),
551 Ref(Cons<And, KSelf>),
553 RefMut(Cons<And, Cons<KMut, KSelf>>),
555 Mut(Cons<KMut, KSelf>),
557 }
558
559 #[derive(Clone)]
561 pub struct NamedParam {
562 pub mut_kw: Option<KMut>,
564 pub name: Ident,
566 pub _colon: Colon,
568 pub param_type: VerbatimUntil<Comma>,
570 }
571
572 #[derive(Clone)]
574 pub struct PatternParam {
575 pub mut_kw: Option<KMut>,
577 pub pattern: Pattern,
579 pub _colon: Colon,
581 pub param_type: VerbatimUntil<Either<Comma, ParenthesisGroup>>,
583 }
584
585 #[derive(Clone)]
587 pub enum Pattern {
588 Ident(Ident),
590 Tuple(TuplePattern),
592 Other(VerbatimUntil<Colon>),
594 }
595
596 #[derive(Clone)]
598 pub struct TuplePattern {
599 pub fields: ParenthesisGroupContaining<Option<CommaDelimitedVec<PatternField>>>,
601 }
602
603 #[derive(Clone)]
605 pub enum PatternField {
606 Ident(Ident),
608 Nested(Pattern),
610 }
611}
612
613impl quote::ToTokens for FnSig {
615 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
616 if let Some(attrs) = &self.attributes {
618 for attr in &attrs.0 {
619 unsynn::ToTokens::to_tokens(attr, tokens);
620 }
621 }
622
623 if let Some(vis) = &self.visibility {
625 quote::ToTokens::to_tokens(vis, tokens);
626 }
627
628 if let Some(const_kw) = &self.const_kw {
630 unsynn::ToTokens::to_tokens(const_kw, tokens);
631 }
632
633 if let Some(async_kw) = &self.async_kw {
635 unsynn::ToTokens::to_tokens(async_kw, tokens);
636 }
637
638 if let Some(unsafe_kw) = &self.unsafe_kw {
640 unsynn::ToTokens::to_tokens(unsafe_kw, tokens);
641 }
642
643 if let Some(extern_kw) = &self.extern_kw {
645 unsynn::ToTokens::to_tokens(extern_kw, tokens);
646 }
647
648 unsynn::ToTokens::to_tokens(&self._fn, tokens);
650 quote::ToTokens::to_tokens(&self.name, tokens);
651
652 if let Some(generics) = &self.generics {
653 unsynn::ToTokens::to_tokens(generics, tokens);
654 }
655
656 unsynn::ToTokens::to_tokens(&self.params, tokens);
657
658 if let Some(ret_type) = &self.return_type {
659 unsynn::ToTokens::to_tokens(ret_type, tokens);
660 }
661
662 if let Some(where_clause) = &self.where_clause {
663 unsynn::ToTokens::to_tokens(where_clause, tokens);
664 }
665
666 unsynn::ToTokens::to_tokens(&self.body, tokens);
667 }
668}
669
670impl quote::ToTokens for TraitMethodSig {
671 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
672 if let Some(attrs) = &self.attributes {
674 for attr in &attrs.0 {
675 unsynn::ToTokens::to_tokens(attr, tokens);
676 }
677 }
678
679 if let Some(const_kw) = &self.const_kw {
681 unsynn::ToTokens::to_tokens(const_kw, tokens);
682 }
683
684 if let Some(async_kw) = &self.async_kw {
686 unsynn::ToTokens::to_tokens(async_kw, tokens);
687 }
688
689 if let Some(unsafe_kw) = &self.unsafe_kw {
691 unsynn::ToTokens::to_tokens(unsafe_kw, tokens);
692 }
693
694 if let Some(extern_kw) = &self.extern_kw {
696 unsynn::ToTokens::to_tokens(extern_kw, tokens);
697 }
698
699 unsynn::ToTokens::to_tokens(&self._fn, tokens);
701 quote::ToTokens::to_tokens(&self.name, tokens);
702
703 if let Some(generics) = &self.generics {
704 unsynn::ToTokens::to_tokens(generics, tokens);
705 }
706
707 unsynn::ToTokens::to_tokens(&self.params, tokens);
708
709 if let Some(ret_type) = &self.return_type {
710 unsynn::ToTokens::to_tokens(ret_type, tokens);
711 }
712
713 if let Some(where_clause) = &self.where_clause {
714 unsynn::ToTokens::to_tokens(where_clause, tokens);
715 }
716
717 unsynn::ToTokens::to_tokens(&self._semi, tokens);
718 }
719}
720
721impl quote::ToTokens for FnParam {
722 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
723 match self {
724 FnParam::SelfParam(self_param) => quote::ToTokens::to_tokens(self_param, tokens),
725 FnParam::Named(named) => quote::ToTokens::to_tokens(named, tokens),
726 FnParam::Pattern(pattern) => quote::ToTokens::to_tokens(pattern, tokens),
727 }
728 }
729}
730
731impl quote::ToTokens for SelfParam {
732 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
733 match self {
734 SelfParam::Value(self_kw) => unsynn::ToTokens::to_tokens(self_kw, tokens),
735 SelfParam::Ref(ref_self) => unsynn::ToTokens::to_tokens(ref_self, tokens),
736 SelfParam::RefMut(ref_mut_self) => unsynn::ToTokens::to_tokens(ref_mut_self, tokens),
737 SelfParam::Mut(mut_self) => unsynn::ToTokens::to_tokens(mut_self, tokens),
738 }
739 }
740}
741
742impl quote::ToTokens for NamedParam {
743 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
744 if let Some(mut_kw) = &self.mut_kw {
745 unsynn::ToTokens::to_tokens(mut_kw, tokens);
746 }
747 quote::ToTokens::to_tokens(&self.name, tokens);
748 unsynn::ToTokens::to_tokens(&self._colon, tokens);
749 unsynn::ToTokens::to_tokens(&self.param_type, tokens);
750 }
751}
752
753impl quote::ToTokens for PatternParam {
754 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
755 if let Some(mut_kw) = &self.mut_kw {
756 unsynn::ToTokens::to_tokens(mut_kw, tokens);
757 }
758 unsynn::ToTokens::to_tokens(&self.pattern, tokens);
759 unsynn::ToTokens::to_tokens(&self._colon, tokens);
760 unsynn::ToTokens::to_tokens(&self.param_type, tokens);
761 }
762}
763
764impl quote::ToTokens for Pattern {
765 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
766 match self {
767 Pattern::Tuple(tuple) => quote::ToTokens::to_tokens(tuple, tokens),
768 Pattern::Ident(ident) => quote::ToTokens::to_tokens(ident, tokens),
769 Pattern::Other(other) => unsynn::ToTokens::to_tokens(other, tokens),
770 }
771 }
772}
773
774impl quote::ToTokens for TuplePattern {
775 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
776 unsynn::ToTokens::to_tokens(&self.fields, tokens);
777 }
778}
779
780impl quote::ToTokens for PatternField {
781 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
782 match self {
783 PatternField::Ident(ident) => quote::ToTokens::to_tokens(ident, tokens),
784 PatternField::Nested(pattern) => quote::ToTokens::to_tokens(pattern, tokens),
785 }
786 }
787}
788
789impl quote::ToTokens for Visibility {
790 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
791 match self {
792 Visibility::Public(pub_kw) => unsynn::ToTokens::to_tokens(pub_kw, tokens),
793 Visibility::Restricted(restricted) => unsynn::ToTokens::to_tokens(restricted, tokens),
794 }
795 }
796}
797
798impl quote::ToTokens for ExternSpec {
799 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
800 match self {
801 ExternSpec::WithAbi(with_abi) => unsynn::ToTokens::to_tokens(with_abi, tokens),
802 ExternSpec::Bare(extern_kw) => unsynn::ToTokens::to_tokens(extern_kw, tokens),
803 }
804 }
805}
806
807impl quote::ToTokens for ReturnTypeTrait {
808 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
809 unsynn::ToTokens::to_tokens(&self._arrow, tokens);
810 unsynn::ToTokens::to_tokens(&self.return_type, tokens);
811 }
812}
813
814impl quote::ToTokens for ReturnTypeFn {
815 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
816 unsynn::ToTokens::to_tokens(&self._arrow, tokens);
817 unsynn::ToTokens::to_tokens(&self.return_type, tokens);
818 }
819}
820
821impl quote::ToTokens for Generics {
822 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
823 unsynn::ToTokens::to_tokens(&self._lt, tokens);
824 unsynn::ToTokens::to_tokens(&self.content, tokens);
825 unsynn::ToTokens::to_tokens(&self._gt, tokens);
826 }
827}
828
829impl quote::ToTokens for WhereClause {
830 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
831 unsynn::ToTokens::to_tokens(&self._pred, tokens);
832 unsynn::ToTokens::to_tokens(&self._colon, tokens);
833 unsynn::ToTokens::to_tokens(&self.bounds, tokens);
834 }
835}
836
837impl quote::ToTokens for WhereClauses {
838 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
839 unsynn::ToTokens::to_tokens(&self._kw_where, tokens);
840 unsynn::ToTokens::to_tokens(&self.clauses, tokens);
841 }
842}
843
844impl quote::ToTokens for Attribute {
845 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
846 unsynn::ToTokens::to_tokens(&self._hash, tokens);
847 unsynn::ToTokens::to_tokens(&self.content, tokens);
848 }
849}
850
851impl quote::ToTokens for InnerAttribute {
852 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
853 unsynn::ToTokens::to_tokens(&self._hash, tokens);
854 unsynn::ToTokens::to_tokens(&self._bang, tokens);
855 unsynn::ToTokens::to_tokens(&self.content, tokens);
856 }
857}
858
859impl quote::ToTokens for AnyAttribute {
860 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
861 match self {
862 AnyAttribute::Inner(inner) => quote::ToTokens::to_tokens(inner, tokens),
863 AnyAttribute::Outer(outer) => quote::ToTokens::to_tokens(outer, tokens),
864 }
865 }
866}
867
868impl quote::ToTokens for RestrictedVis {
869 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
870 unsynn::ToTokens::to_tokens(&self._pub, tokens);
871 unsynn::ToTokens::to_tokens(&self.restriction, tokens);
872 }
873}
874
875impl quote::ToTokens for ExternWithAbi {
876 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
877 unsynn::ToTokens::to_tokens(&self._extern, tokens);
878 unsynn::ToTokens::to_tokens(&self.abi, tokens);
879 }
880}
881
882impl quote::ToTokens for ModuleItem {
883 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
884 match self {
885 ModuleItem::TraitMethod(method) => quote::ToTokens::to_tokens(method, tokens),
886 ModuleItem::Function(func) => quote::ToTokens::to_tokens(func, tokens),
887 ModuleItem::ImplBlock(impl_block) => quote::ToTokens::to_tokens(impl_block, tokens),
888 ModuleItem::Module(module) => quote::ToTokens::to_tokens(module, tokens),
889 ModuleItem::Trait(trait_def) => quote::ToTokens::to_tokens(trait_def, tokens),
890 ModuleItem::Enum(enum_sig) => quote::ToTokens::to_tokens(enum_sig, tokens),
891 ModuleItem::Struct(struct_sig) => quote::ToTokens::to_tokens(struct_sig, tokens),
892 ModuleItem::TypeAlias(type_alias) => quote::ToTokens::to_tokens(type_alias, tokens),
893 ModuleItem::Const(const_sig) => quote::ToTokens::to_tokens(const_sig, tokens),
894 ModuleItem::Static(static_sig) => quote::ToTokens::to_tokens(static_sig, tokens),
895 ModuleItem::Other(token_tree) => unsynn::ToTokens::to_tokens(token_tree, tokens),
896 }
897 }
898}
899
900impl quote::ToTokens for ImplBlockSig {
901 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
902 if let Some(attrs) = &self.attributes {
903 for attr in &attrs.0 {
904 unsynn::ToTokens::to_tokens(attr, tokens);
905 }
906 }
907 unsynn::ToTokens::to_tokens(&self._impl, tokens);
908 if let Some(generics) = &self.generics {
909 unsynn::ToTokens::to_tokens(generics, tokens);
910 }
911 unsynn::ToTokens::to_tokens(&self.target_type, tokens);
912 if let Some(for_trait) = &self.for_trait {
913 unsynn::ToTokens::to_tokens(for_trait, tokens);
914 }
915 if let Some(where_clause) = &self.where_clause {
916 unsynn::ToTokens::to_tokens(where_clause, tokens);
917 }
918 unsynn::ToTokens::to_tokens(&self.items, tokens);
919 }
920}
921
922impl quote::ToTokens for ModuleSig {
923 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
924 if let Some(attrs) = &self.attributes {
925 for attr in &attrs.0 {
926 unsynn::ToTokens::to_tokens(attr, tokens);
927 }
928 }
929 if let Some(vis) = &self.visibility {
930 quote::ToTokens::to_tokens(vis, tokens);
931 }
932 unsynn::ToTokens::to_tokens(&self._mod, tokens);
933 quote::ToTokens::to_tokens(&self.name, tokens);
934 unsynn::ToTokens::to_tokens(&self.items, tokens);
935 }
936}
937
938impl quote::ToTokens for TraitSig {
939 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
940 if let Some(attrs) = &self.attributes {
941 for attr in &attrs.0 {
942 unsynn::ToTokens::to_tokens(attr, tokens);
943 }
944 }
945 if let Some(vis) = &self.visibility {
946 quote::ToTokens::to_tokens(vis, tokens);
947 }
948 if let Some(unsafe_kw) = &self.unsafe_kw {
949 unsynn::ToTokens::to_tokens(unsafe_kw, tokens);
950 }
951 unsynn::ToTokens::to_tokens(&self._trait, tokens);
952 quote::ToTokens::to_tokens(&self.name, tokens);
953 if let Some(generics) = &self.generics {
954 unsynn::ToTokens::to_tokens(generics, tokens);
955 }
956 if let Some(bounds) = &self.bounds {
957 unsynn::ToTokens::to_tokens(bounds, tokens);
958 }
959 if let Some(where_clause) = &self.where_clause {
960 unsynn::ToTokens::to_tokens(where_clause, tokens);
961 }
962 unsynn::ToTokens::to_tokens(&self.items, tokens);
963 }
964}
965
966impl quote::ToTokens for ModuleContent {
967 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
968 if let Some(inner_attrs) = &self.inner_attrs {
970 for attr_delimited in &inner_attrs.0 {
971 quote::ToTokens::to_tokens(&attr_delimited.value, tokens);
972 }
973 }
974 unsynn::ToTokens::to_tokens(&self.items, tokens);
975 }
976}
977
978impl quote::ToTokens for EnumSig {
979 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
980 if let Some(attrs) = &self.attributes {
981 for attr in &attrs.0 {
982 unsynn::ToTokens::to_tokens(attr, tokens);
983 }
984 }
985 if let Some(vis) = &self.visibility {
986 quote::ToTokens::to_tokens(vis, tokens);
987 }
988 unsynn::ToTokens::to_tokens(&self._enum, tokens);
989 quote::ToTokens::to_tokens(&self.name, tokens);
990 if let Some(generics) = &self.generics {
991 unsynn::ToTokens::to_tokens(generics, tokens);
992 }
993 if let Some(where_clause) = &self.where_clause {
994 unsynn::ToTokens::to_tokens(where_clause, tokens);
995 }
996 unsynn::ToTokens::to_tokens(&self.variants, tokens);
997 }
998}
999
1000impl quote::ToTokens for StructSig {
1001 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1002 if let Some(attrs) = &self.attributes {
1003 for attr in &attrs.0 {
1004 unsynn::ToTokens::to_tokens(attr, tokens);
1005 }
1006 }
1007 if let Some(vis) = &self.visibility {
1008 quote::ToTokens::to_tokens(vis, tokens);
1009 }
1010 unsynn::ToTokens::to_tokens(&self._struct, tokens);
1011 quote::ToTokens::to_tokens(&self.name, tokens);
1012 if let Some(generics) = &self.generics {
1013 unsynn::ToTokens::to_tokens(generics, tokens);
1014 }
1015 if let Some(where_clause) = &self.where_clause {
1016 unsynn::ToTokens::to_tokens(where_clause, tokens);
1017 }
1018 quote::ToTokens::to_tokens(&self.body, tokens);
1019 }
1020}
1021
1022impl quote::ToTokens for StructBody {
1023 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1024 match self {
1025 StructBody::Named(fields) => unsynn::ToTokens::to_tokens(fields, tokens),
1026 StructBody::Tuple(tuple) => unsynn::ToTokens::to_tokens(tuple, tokens),
1027 StructBody::Unit(semi) => unsynn::ToTokens::to_tokens(semi, tokens),
1028 }
1029 }
1030}
1031
1032impl quote::ToTokens for StructField {
1033 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1034 if let Some(attrs) = &self.attributes {
1035 for attr in &attrs.0 {
1036 unsynn::ToTokens::to_tokens(attr, tokens);
1037 }
1038 }
1039 if let Some(vis) = &self.visibility {
1040 quote::ToTokens::to_tokens(vis, tokens);
1041 }
1042 quote::ToTokens::to_tokens(&self.name, tokens);
1043 unsynn::ToTokens::to_tokens(&self._colon, tokens);
1044 unsynn::ToTokens::to_tokens(&self.field_type, tokens);
1045 }
1046}
1047
1048impl quote::ToTokens for TypeAliasSig {
1049 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1050 if let Some(attrs) = &self.attributes {
1051 for attr in &attrs.0 {
1052 unsynn::ToTokens::to_tokens(attr, tokens);
1053 }
1054 }
1055 if let Some(vis) = &self.visibility {
1056 quote::ToTokens::to_tokens(vis, tokens);
1057 }
1058 unsynn::ToTokens::to_tokens(&self._type, tokens);
1059 quote::ToTokens::to_tokens(&self.name, tokens);
1060 if let Some(generics) = &self.generics {
1061 unsynn::ToTokens::to_tokens(generics, tokens);
1062 }
1063 unsynn::ToTokens::to_tokens(&self._eq, tokens);
1064 unsynn::ToTokens::to_tokens(&self.target, tokens);
1065 unsynn::ToTokens::to_tokens(&self._semi, tokens);
1066 }
1067}
1068
1069impl quote::ToTokens for ConstSig {
1070 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1071 if let Some(attrs) = &self.attributes {
1072 for attr in &attrs.0 {
1073 unsynn::ToTokens::to_tokens(attr, tokens);
1074 }
1075 }
1076 if let Some(vis) = &self.visibility {
1077 quote::ToTokens::to_tokens(vis, tokens);
1078 }
1079 unsynn::ToTokens::to_tokens(&self._const, tokens);
1080 quote::ToTokens::to_tokens(&self.name, tokens);
1081 unsynn::ToTokens::to_tokens(&self._colon, tokens);
1082 unsynn::ToTokens::to_tokens(&self.const_type, tokens);
1083 unsynn::ToTokens::to_tokens(&self._eq, tokens);
1084 unsynn::ToTokens::to_tokens(&self.value, tokens);
1085 unsynn::ToTokens::to_tokens(&self._semi, tokens);
1086 }
1087}
1088
1089impl quote::ToTokens for StaticSig {
1090 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1091 if let Some(attrs) = &self.attributes {
1092 for attr in &attrs.0 {
1093 unsynn::ToTokens::to_tokens(attr, tokens);
1094 }
1095 }
1096 if let Some(vis) = &self.visibility {
1097 quote::ToTokens::to_tokens(vis, tokens);
1098 }
1099 if let Some(mut_kw) = &self.mut_kw {
1100 unsynn::ToTokens::to_tokens(mut_kw, tokens);
1101 }
1102 unsynn::ToTokens::to_tokens(&self._static, tokens);
1103 quote::ToTokens::to_tokens(&self.name, tokens);
1104 unsynn::ToTokens::to_tokens(&self._colon, tokens);
1105 unsynn::ToTokens::to_tokens(&self.static_type, tokens);
1106 unsynn::ToTokens::to_tokens(&self._eq, tokens);
1107 unsynn::ToTokens::to_tokens(&self.value, tokens);
1108 unsynn::ToTokens::to_tokens(&self._semi, tokens);
1109 }
1110}
1111
1112impl quote::ToTokens for EnumVariant {
1113 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1114 if let Some(attrs) = &self.attributes {
1115 for attr in &attrs.0 {
1116 unsynn::ToTokens::to_tokens(attr, tokens);
1117 }
1118 }
1119 quote::ToTokens::to_tokens(&self.name, tokens);
1120 if let Some(data) = &self.data {
1121 quote::ToTokens::to_tokens(data, tokens);
1122 }
1123 }
1124}
1125
1126impl quote::ToTokens for EnumVariantData {
1127 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
1128 match self {
1129 EnumVariantData::Tuple(paren) => unsynn::ToTokens::to_tokens(paren, tokens),
1130 EnumVariantData::Struct(brace) => unsynn::ToTokens::to_tokens(brace, tokens),
1131 EnumVariantData::Discriminant(disc) => unsynn::ToTokens::to_tokens(disc, tokens),
1132 }
1133 }
1134}
1135
1136#[cfg(test)]
1137#[path = "tests/parse.rs"]
1138mod tests;