@@ -73,7 +73,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
73
73
impl < ' a , ' b : ' a > DebugStruct < ' a , ' b > {
74
74
/// Adds a new field to the generated struct output.
75
75
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
76
- pub fn field ( mut self , name : & str , value : & fmt:: Debug ) -> DebugStruct < ' a , ' b > {
76
+ pub fn field ( & mut self , name : & str , value : & fmt:: Debug ) -> & mut DebugStruct < ' a , ' b > {
77
77
self . result = self . result . and_then ( |_| {
78
78
let prefix = if self . has_fields {
79
79
","
@@ -96,7 +96,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
96
96
/// Consumes the `DebugStruct`, finishing output and returning any error
97
97
/// encountered.
98
98
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
99
- pub fn finish ( mut self ) -> fmt:: Result {
99
+ pub fn finish ( & mut self ) -> fmt:: Result {
100
100
if self . has_fields {
101
101
self . result = self . result . and_then ( |_| {
102
102
if self . is_pretty ( ) {
@@ -136,7 +136,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
136
136
impl < ' a , ' b : ' a > DebugTuple < ' a , ' b > {
137
137
/// Adds a new field to the generated tuple struct output.
138
138
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
139
- pub fn field ( mut self , value : & fmt:: Debug ) -> DebugTuple < ' a , ' b > {
139
+ pub fn field ( & mut self , value : & fmt:: Debug ) -> & mut DebugTuple < ' a , ' b > {
140
140
self . result = self . result . and_then ( |_| {
141
141
let ( prefix, space) = if self . has_fields {
142
142
( "," , " " )
@@ -159,7 +159,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
159
159
/// Consumes the `DebugTuple`, finishing output and returning any error
160
160
/// encountered.
161
161
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
162
- pub fn finish ( mut self ) -> fmt:: Result {
162
+ pub fn finish ( & mut self ) -> fmt:: Result {
163
163
if self . has_fields {
164
164
self . result = self . result . and_then ( |_| {
165
165
if self . is_pretty ( ) {
@@ -231,15 +231,25 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
231
231
impl < ' a , ' b : ' a > DebugSet < ' a , ' b > {
232
232
/// Adds a new entry to the set output.
233
233
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
234
- pub fn entry ( mut self , entry : & fmt:: Debug ) -> DebugSet < ' a , ' b > {
234
+ pub fn entry ( & mut self , entry : & fmt:: Debug ) -> & mut DebugSet < ' a , ' b > {
235
235
self . inner . entry ( entry) ;
236
236
self
237
237
}
238
238
239
+ /// Adds the contents of an iterator of entries to the set output.
240
+ #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
241
+ pub fn entries < D , I > ( & mut self , entries : I ) -> & mut DebugSet < ' a , ' b >
242
+ where D : fmt:: Debug , I : IntoIterator < Item =D > {
243
+ for entry in entries {
244
+ self . entry ( & entry) ;
245
+ }
246
+ self
247
+ }
248
+
239
249
/// Consumes the `DebugSet`, finishing output and returning any error
240
250
/// encountered.
241
251
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
242
- pub fn finish ( mut self ) -> fmt:: Result {
252
+ pub fn finish ( & mut self ) -> fmt:: Result {
243
253
self . inner . finish ( ) ;
244
254
self . inner . result . and_then ( |_| self . inner . fmt . write_str ( "}" ) )
245
255
}
@@ -265,17 +275,27 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
265
275
}
266
276
267
277
impl < ' a , ' b : ' a > DebugList < ' a , ' b > {
268
- /// Adds a new entry to the set output.
278
+ /// Adds a new entry to the list output.
269
279
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
270
- pub fn entry ( mut self , entry : & fmt:: Debug ) -> DebugList < ' a , ' b > {
280
+ pub fn entry ( & mut self , entry : & fmt:: Debug ) -> & mut DebugList < ' a , ' b > {
271
281
self . inner . entry ( entry) ;
272
282
self
273
283
}
274
284
285
+ /// Adds the contents of an iterator of entries to the list output.
286
+ #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
287
+ pub fn entries < D , I > ( & mut self , entries : I ) -> & mut DebugList < ' a , ' b >
288
+ where D : fmt:: Debug , I : IntoIterator < Item =D > {
289
+ for entry in entries {
290
+ self . entry ( & entry) ;
291
+ }
292
+ self
293
+ }
294
+
275
295
/// Consumes the `DebugSet`, finishing output and returning any error
276
296
/// encountered.
277
297
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
278
- pub fn finish ( mut self ) -> fmt:: Result {
298
+ pub fn finish ( & mut self ) -> fmt:: Result {
279
299
self . inner . finish ( ) ;
280
300
self . inner . result . and_then ( |_| self . inner . fmt . write_str ( "]" ) )
281
301
}
@@ -303,7 +323,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
303
323
impl < ' a , ' b : ' a > DebugMap < ' a , ' b > {
304
324
/// Adds a new entry to the map output.
305
325
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
306
- pub fn entry ( mut self , key : & fmt:: Debug , value : & fmt:: Debug ) -> DebugMap < ' a , ' b > {
326
+ pub fn entry ( & mut self , key : & fmt:: Debug , value : & fmt:: Debug ) -> & mut DebugMap < ' a , ' b > {
307
327
self . result = self . result . and_then ( |_| {
308
328
if self . is_pretty ( ) {
309
329
let mut writer = PadAdapter :: new ( self . fmt ) ;
@@ -319,10 +339,20 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
319
339
self
320
340
}
321
341
342
+ /// Adds the contents of an iterator of entries to the map output.
343
+ #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
344
+ pub fn entries < K , V , I > ( & mut self , entries : I ) -> & mut DebugMap < ' a , ' b >
345
+ where K : fmt:: Debug , V : fmt:: Debug , I : IntoIterator < Item =( K , V ) > {
346
+ for ( k, v) in entries {
347
+ self . entry ( & k, & v) ;
348
+ }
349
+ self
350
+ }
351
+
322
352
/// Consumes the `DebugMap`, finishing output and returning any error
323
353
/// encountered.
324
354
#[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
325
- pub fn finish ( self ) -> fmt:: Result {
355
+ pub fn finish ( & mut self ) -> fmt:: Result {
326
356
let prefix = if self . is_pretty ( ) && self . has_fields { "\n " } else { "" } ;
327
357
self . result . and_then ( |_| write ! ( self . fmt, "{}}}" , prefix) )
328
358
}
0 commit comments