@@ -73,7 +73,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
7373impl < ' a , ' b : ' a > DebugStruct < ' a , ' b > {
7474 /// Adds a new field to the generated struct output.
7575 #[ 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 > {
7777 self . result = self . result . and_then ( |_| {
7878 let prefix = if self . has_fields {
7979 ","
@@ -96,7 +96,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
9696 /// Consumes the `DebugStruct`, finishing output and returning any error
9797 /// encountered.
9898 #[ 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 {
100100 if self . has_fields {
101101 self . result = self . result . and_then ( |_| {
102102 if self . is_pretty ( ) {
@@ -136,7 +136,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
136136impl < ' a , ' b : ' a > DebugTuple < ' a , ' b > {
137137 /// Adds a new field to the generated tuple struct output.
138138 #[ 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 > {
140140 self . result = self . result . and_then ( |_| {
141141 let ( prefix, space) = if self . has_fields {
142142 ( "," , " " )
@@ -159,7 +159,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
159159 /// Consumes the `DebugTuple`, finishing output and returning any error
160160 /// encountered.
161161 #[ 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 {
163163 if self . has_fields {
164164 self . result = self . result . and_then ( |_| {
165165 if self . is_pretty ( ) {
@@ -231,15 +231,25 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
231231impl < ' a , ' b : ' a > DebugSet < ' a , ' b > {
232232 /// Adds a new entry to the set output.
233233 #[ 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 > {
235235 self . inner . entry ( entry) ;
236236 self
237237 }
238238
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+
239249 /// Consumes the `DebugSet`, finishing output and returning any error
240250 /// encountered.
241251 #[ 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 {
243253 self . inner . finish ( ) ;
244254 self . inner . result . and_then ( |_| self . inner . fmt . write_str ( "}" ) )
245255 }
@@ -265,17 +275,27 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
265275}
266276
267277impl < ' a , ' b : ' a > DebugList < ' a , ' b > {
268- /// Adds a new entry to the set output.
278+ /// Adds a new entry to the list output.
269279 #[ 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 > {
271281 self . inner . entry ( entry) ;
272282 self
273283 }
274284
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+
275295 /// Consumes the `DebugSet`, finishing output and returning any error
276296 /// encountered.
277297 #[ 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 {
279299 self . inner . finish ( ) ;
280300 self . inner . result . and_then ( |_| self . inner . fmt . write_str ( "]" ) )
281301 }
@@ -303,7 +323,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
303323impl < ' a , ' b : ' a > DebugMap < ' a , ' b > {
304324 /// Adds a new entry to the map output.
305325 #[ 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 > {
307327 self . result = self . result . and_then ( |_| {
308328 if self . is_pretty ( ) {
309329 let mut writer = PadAdapter :: new ( self . fmt ) ;
@@ -319,10 +339,20 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
319339 self
320340 }
321341
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+
322352 /// Consumes the `DebugMap`, finishing output and returning any error
323353 /// encountered.
324354 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
325- pub fn finish ( self ) -> fmt:: Result {
355+ pub fn finish ( & mut self ) -> fmt:: Result {
326356 let prefix = if self . is_pretty ( ) && self . has_fields { "\n " } else { "" } ;
327357 self . result . and_then ( |_| write ! ( self . fmt, "{}}}" , prefix) )
328358 }
0 commit comments