1use syn::punctuated::{Pair, Punctuated};
2
3#[allow(clippy::match_single_binding, unused_variables)]
4mod gen;
5
6use crate::{DebugPls, Formatter};
7
8struct DebugSelf<T>(T);
9impl<T: Into<syn::Expr> + Clone> DebugPls for DebugSelf<T> {
10 fn fmt(&self, f: Formatter<'_>) {
11 f.write_expr(self.0.clone());
12 }
13}
14
15struct DebugLit<T>(T);
16impl<T: Into<syn::Lit> + Clone> DebugPls for DebugLit<T> {
17 fn fmt(&self, f: Formatter<'_>) {
18 f.write_expr(syn::Expr::Lit(syn::ExprLit {
19 attrs: vec![],
20 lit: self.0.clone().into(),
21 }));
22 }
23}
24
25impl DebugPls for syn::LitStr {
26 fn fmt(&self, f: Formatter<'_>) {
27 f.debug_struct("LitStr")
28 .field("token", &DebugLit(self.clone()))
29 .finish();
30 }
31}
32
33impl DebugPls for syn::LitInt {
34 fn fmt(&self, f: Formatter<'_>) {
35 f.debug_struct("LitInt")
36 .field("token", &DebugLit(self.clone()))
37 .finish();
38 }
39}
40
41impl DebugPls for syn::LitByte {
42 fn fmt(&self, f: Formatter<'_>) {
43 f.debug_struct("LitByte")
44 .field("token", &DebugLit(self.clone()))
45 .finish();
46 }
47}
48
49impl DebugPls for syn::LitChar {
50 fn fmt(&self, f: Formatter<'_>) {
51 f.debug_struct("LitChar")
52 .field("token", &DebugLit(self.clone()))
53 .finish();
54 }
55}
56
57impl DebugPls for syn::LitBool {
58 fn fmt(&self, f: Formatter<'_>) {
59 f.debug_struct("LitBool")
60 .field("token", &DebugLit(self.clone()))
61 .finish();
62 }
63}
64
65impl DebugPls for syn::LitFloat {
66 fn fmt(&self, f: Formatter<'_>) {
67 f.debug_struct("LitFloat")
68 .field("token", &DebugLit(self.clone()))
69 .finish();
70 }
71}
72
73impl DebugPls for syn::LitByteStr {
74 fn fmt(&self, f: Formatter<'_>) {
75 f.debug_struct("LitByteStr")
76 .field("token", &DebugLit(self.clone()))
77 .finish();
78 }
79}
80
81impl DebugPls for syn::token::Group {
82 fn fmt(&self, f: Formatter<'_>) {
83 f.debug_ident("Group");
84 }
85}
86
87impl DebugPls for syn::token::Brace {
88 fn fmt(&self, f: Formatter<'_>) {
89 f.debug_ident("Brace");
90 }
91}
92
93impl DebugPls for syn::token::Bracket {
94 fn fmt(&self, f: Formatter<'_>) {
95 f.debug_ident("Bracket");
96 }
97}
98
99impl DebugPls for syn::token::Paren {
100 fn fmt(&self, f: Formatter<'_>) {
101 f.debug_ident("Paren");
102 }
103}
104
105impl<T: DebugPls, P: DebugPls> DebugPls for Punctuated<T, P> {
106 fn fmt(&self, f: Formatter<'_>) {
107 self.pairs()
108 .fold(f.debug_list(), |f, pair| match pair {
109 Pair::Punctuated(t, p) => f.entry(t).entry(p),
110 Pair::End(t) => f.entry(t),
111 })
112 .finish();
113 }
114}