term_rustdoc/tree/impls/
debug.rs1use super::super::*;
2use std::fmt::{self, Debug};
3
4macro_rules! skip_fmt {
6 ($base:ident, $self:ident . $($field:ident)+ ) => {$(
7 if !$self.$field.is_empty() {
8 $base.field(::std::stringify!($field), &$self.$field);
9 }
10 )+};
11 (bool: $base:ident, $self:ident . $($field:ident)+ ) => {$(
12 if $self.$field {
13 $base.field(::std::stringify!($field), &$self.$field);
14 }
15 )+};
16 (option: $base:ident, $self:ident . $($field:ident)+ ) => {$(
17 if $self.$field.is_some() {
18 $base.field(::std::stringify!($field), &$self.$field);
19 }
20 )+};
21 (0: $base:ident, $self:ident . $($field:ident)+ ) => {$(
22 if $self.$field != 0 {
23 $base.field(::std::stringify!($field), &$self.$field);
24 }
25 )+};
26}
27
28impl Debug for DModule {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 let mut base = f.debug_struct("DModule");
31 base.field("id", &self.id);
32 skip_fmt!(
33 base, self . modules structs unions enums
34 functions traits constants statics type_alias
35 macros_decl macros_func macros_attr macros_derv
36 );
37 base.finish()
38 }
39}
40
41impl Debug for DImpl {
42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43 let mut base = f.debug_struct("DImpl");
44 skip_fmt!(base, self . inherent trait_ auto blanket);
45 base.finish()
46 }
47}
48
49impl Debug for DImplInner {
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 let mut base = f.debug_struct("DImplInner");
52 base.field("id", &self.id);
53 skip_fmt!(base, self . functions constants types);
54 base.finish()
55 }
56}
57
58impl Debug for DStruct {
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60 let mut base = f.debug_struct("DStruct");
61 base.field("id", &self.id);
62 skip_fmt!(bool: base, self.contain_private_fields);
63 skip_fmt!(base, self . fields impls);
64 base.finish()
65 }
66}
67
68impl Debug for DUnion {
69 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
70 let mut base = f.debug_struct("DUnion");
71 base.field("id", &self.id);
72 skip_fmt!(
73 base, self . fields impls
74 );
75 base.finish()
76 }
77}
78
79impl Debug for DEnum {
80 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
81 let mut base = f.debug_struct("DEnum");
82 base.field("id", &self.id);
83 skip_fmt!(base, self . variants impls);
84 base.finish()
85 }
86}
87
88impl Debug for DTrait {
89 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
90 let mut base = f.debug_struct("DTrait");
91 base.field("id", &self.id);
92 skip_fmt!(base, self . types constants functions implementations);
93 base.finish()
94 }
95}
96
97impl Debug for ItemCount {
98 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
99 let mut base = f.debug_struct("ItemCount");
100 skip_fmt!(
101 0: base, self . modules structs unions enums functions
102 traits constants statics type_alias
103 macros_decl macros_func macros_attr macros_derv
104 );
105 base.finish()
106 }
107}
108
109impl Debug for ImplCount {
110 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
111 let mut base = f.debug_struct("ImplCount");
112 if self.total != 0 {
113 base.field("kind", &self.kind);
114 base.field("total", &self.total);
115 skip_fmt!(0: base, self . structs enums unions);
116 }
117 base.finish()
118 }
119}
120
121impl Debug for ImplCounts {
122 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
123 let mut base = f.debug_struct("ImplCounts");
124 if self.total.total != 0 {
125 base.field("total", &self.total);
126 if self.inherent.total != 0 {
127 base.field("inherent", &self.inherent);
128 }
129 if self.trait_.total != 0 {
130 base.field("trait", &self.trait_);
131 }
132 }
133 base.finish()
134 }
135}