@@ -63,8 +63,13 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
63
63
impl < ' a , ' b : ' a > DebugStruct < ' a , ' b > {
64
64
/// Adds a new field to the generated struct output.
65
65
#[ unstable( feature = "core" , reason = "method was just created" ) ]
66
- pub fn field < S > ( mut self , name : & str , value : & S ) -> DebugStruct < ' a , ' b >
67
- where S : fmt:: Debug {
66
+ #[ inline]
67
+ pub fn field ( mut self , name : & str , value : & fmt:: Debug ) -> DebugStruct < ' a , ' b > {
68
+ self . field_inner ( name, value) ;
69
+ self
70
+ }
71
+
72
+ fn field_inner ( & mut self , name : & str , value : & fmt:: Debug ) {
68
73
self . result = self . result . and_then ( |_| {
69
74
let prefix = if self . has_fields {
70
75
","
@@ -81,13 +86,18 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
81
86
} ) ;
82
87
83
88
self . has_fields = true ;
84
- self
85
89
}
86
90
87
91
/// Consumes the `DebugStruct`, finishing output and returning any error
88
92
/// encountered.
89
93
#[ unstable( feature = "core" , reason = "method was just created" ) ]
94
+ #[ inline]
90
95
pub fn finish ( mut self ) -> fmt:: Result {
96
+ self . finish_inner ( ) ;
97
+ self . result
98
+ }
99
+
100
+ fn finish_inner ( & mut self ) {
91
101
if self . has_fields {
92
102
self . result = self . result . and_then ( |_| {
93
103
if self . is_pretty ( ) {
@@ -97,7 +107,6 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
97
107
}
98
108
} ) ;
99
109
}
100
- self . result
101
110
}
102
111
103
112
fn is_pretty ( & self ) -> bool {
@@ -127,7 +136,13 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
127
136
impl < ' a , ' b : ' a > DebugTuple < ' a , ' b > {
128
137
/// Adds a new field to the generated tuple struct output.
129
138
#[ unstable( feature = "core" , reason = "method was just created" ) ]
130
- pub fn field < S > ( mut self , value : & S ) -> DebugTuple < ' a , ' b > where S : fmt:: Debug {
139
+ #[ inline]
140
+ pub fn field ( mut self , value : & fmt:: Debug ) -> DebugTuple < ' a , ' b > {
141
+ self . field_inner ( value) ;
142
+ self
143
+ }
144
+
145
+ fn field_inner ( & mut self , value : & fmt:: Debug ) {
131
146
self . result = self . result . and_then ( |_| {
132
147
let ( prefix, space) = if self . has_fields {
133
148
( "," , " " )
@@ -144,13 +159,18 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
144
159
} ) ;
145
160
146
161
self . has_fields = true ;
147
- self
148
162
}
149
163
150
164
/// Consumes the `DebugTuple`, finishing output and returning any error
151
165
/// encountered.
152
166
#[ unstable( feature = "core" , reason = "method was just created" ) ]
167
+ #[ inline]
153
168
pub fn finish ( mut self ) -> fmt:: Result {
169
+ self . finish_inner ( ) ;
170
+ self . result
171
+ }
172
+
173
+ fn finish_inner ( & mut self ) {
154
174
if self . has_fields {
155
175
self . result = self . result . and_then ( |_| {
156
176
if self . is_pretty ( ) {
@@ -160,7 +180,6 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
160
180
}
161
181
} ) ;
162
182
}
163
- self . result
164
183
}
165
184
166
185
fn is_pretty ( & self ) -> bool {
@@ -190,7 +209,13 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> Deb
190
209
impl < ' a , ' b : ' a > DebugSet < ' a , ' b > {
191
210
/// Adds a new entry to the set output.
192
211
#[ unstable( feature = "core" , reason = "method was just created" ) ]
193
- pub fn entry < S > ( mut self , entry : & S ) -> DebugSet < ' a , ' b > where S : fmt:: Debug {
212
+ #[ inline]
213
+ pub fn entry ( mut self , entry : & fmt:: Debug ) -> DebugSet < ' a , ' b > {
214
+ self . entry_inner ( entry) ;
215
+ self
216
+ }
217
+
218
+ fn entry_inner ( & mut self , entry : & fmt:: Debug ) {
194
219
self . result = self . result . and_then ( |_| {
195
220
let prefix = if self . has_fields {
196
221
","
@@ -207,21 +232,26 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
207
232
} ) ;
208
233
209
234
self . has_fields = true ;
210
- self
211
235
}
212
236
213
237
/// Consumes the `DebugSet`, finishing output and returning any error
214
238
/// encountered.
215
239
#[ unstable( feature = "core" , reason = "method was just created" ) ]
216
- pub fn finish ( self ) -> fmt:: Result {
217
- self . result . and_then ( |_| {
240
+ #[ inline]
241
+ pub fn finish ( mut self ) -> fmt:: Result {
242
+ self . finish_inner ( ) ;
243
+ self . result
244
+ }
245
+
246
+ fn finish_inner ( & mut self ) {
247
+ self . result = self . result . and_then ( |_| {
218
248
let end = match ( self . has_fields , self . is_pretty ( ) ) {
219
249
( false , _) => "}" ,
220
250
( true , false ) => " }" ,
221
251
( true , true ) => "\n }" ,
222
252
} ;
223
253
self . fmt . write_str ( end)
224
- } )
254
+ } ) ;
225
255
}
226
256
227
257
fn is_pretty ( & self ) -> bool {
@@ -251,8 +281,13 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> Deb
251
281
impl < ' a , ' b : ' a > DebugMap < ' a , ' b > {
252
282
/// Adds a new entry to the map output.
253
283
#[ unstable( feature = "core" , reason = "method was just created" ) ]
254
- pub fn entry < K , V > ( mut self , key : & K , value : & V ) -> DebugMap < ' a , ' b >
255
- where K : fmt:: Debug , V : fmt:: Debug {
284
+ #[ inline]
285
+ pub fn entry ( mut self , key : & fmt:: Debug , value : & fmt:: Debug ) -> DebugMap < ' a , ' b > {
286
+ self . entry_inner ( key, value) ;
287
+ self
288
+ }
289
+
290
+ fn entry_inner ( & mut self , key : & fmt:: Debug , value : & fmt:: Debug ) {
256
291
self . result = self . result . and_then ( |_| {
257
292
let prefix = if self . has_fields {
258
293
","
@@ -269,21 +304,26 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
269
304
} ) ;
270
305
271
306
self . has_fields = true ;
272
- self
273
307
}
274
308
275
309
/// Consumes the `DebugMap`, finishing output and returning any error
276
310
/// encountered.
277
311
#[ unstable( feature = "core" , reason = "method was just created" ) ]
278
- pub fn finish ( self ) -> fmt:: Result {
279
- self . result . and_then ( |_| {
312
+ #[ inline]
313
+ pub fn finish ( mut self ) -> fmt:: Result {
314
+ self . finish_inner ( ) ;
315
+ self . result
316
+ }
317
+
318
+ fn finish_inner ( & mut self ) {
319
+ self . result = self . result . and_then ( |_| {
280
320
let end = match ( self . has_fields , self . is_pretty ( ) ) {
281
321
( false , _) => "}" ,
282
322
( true , false ) => " }" ,
283
323
( true , true ) => "\n }" ,
284
324
} ;
285
325
self . fmt . write_str ( end)
286
- } )
326
+ } ) ;
287
327
}
288
328
289
329
fn is_pretty ( & self ) -> bool {
0 commit comments