@@ -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 ","
@@ -93,10 +93,9 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
9393 self
9494 }
9595
96- /// Consumes the `DebugStruct`, finishing output and returning any error
97- /// encountered.
96+ /// Finishes output and returns any error encountered.
9897 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
99- pub fn finish ( mut self ) -> fmt:: Result {
98+ pub fn finish ( & mut self ) -> fmt:: Result {
10099 if self . has_fields {
101100 self . result = self . result . and_then ( |_| {
102101 if self . is_pretty ( ) {
@@ -136,7 +135,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
136135impl < ' a , ' b : ' a > DebugTuple < ' a , ' b > {
137136 /// Adds a new field to the generated tuple struct output.
138137 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
139- pub fn field ( mut self , value : & fmt:: Debug ) -> DebugTuple < ' a , ' b > {
138+ pub fn field ( & mut self , value : & fmt:: Debug ) -> & mut DebugTuple < ' a , ' b > {
140139 self . result = self . result . and_then ( |_| {
141140 let ( prefix, space) = if self . has_fields {
142141 ( "," , " " )
@@ -156,10 +155,9 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
156155 self
157156 }
158157
159- /// Consumes the `DebugTuple`, finishing output and returning any error
160- /// encountered.
158+ /// Finishes output and returns any error encountered.
161159 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
162- pub fn finish ( mut self ) -> fmt:: Result {
160+ pub fn finish ( & mut self ) -> fmt:: Result {
163161 if self . has_fields {
164162 self . result = self . result . and_then ( |_| {
165163 if self . is_pretty ( ) {
@@ -231,15 +229,24 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
231229impl < ' a , ' b : ' a > DebugSet < ' a , ' b > {
232230 /// Adds a new entry to the set output.
233231 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
234- pub fn entry ( mut self , entry : & fmt:: Debug ) -> DebugSet < ' a , ' b > {
232+ pub fn entry ( & mut self , entry : & fmt:: Debug ) -> & mut DebugSet < ' a , ' b > {
235233 self . inner . entry ( entry) ;
236234 self
237235 }
238236
239- /// Consumes the `DebugSet`, finishing output and returning any error
240- /// encountered.
237+ /// Adds the contents of an iterator of entries to the set output.
241238 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
242- pub fn finish ( mut self ) -> fmt:: Result {
239+ pub fn entries < D , I > ( & mut self , entries : I ) -> & mut DebugSet < ' a , ' b >
240+ where D : fmt:: Debug , I : IntoIterator < Item =D > {
241+ for entry in entries {
242+ self . entry ( & entry) ;
243+ }
244+ self
245+ }
246+
247+ /// Finishes output and returns any error encountered.
248+ #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
249+ pub fn finish ( & mut self ) -> fmt:: Result {
243250 self . inner . finish ( ) ;
244251 self . inner . result . and_then ( |_| self . inner . fmt . write_str ( "}" ) )
245252 }
@@ -265,17 +272,26 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
265272}
266273
267274impl < ' a , ' b : ' a > DebugList < ' a , ' b > {
268- /// Adds a new entry to the set output.
275+ /// Adds a new entry to the list output.
269276 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
270- pub fn entry ( mut self , entry : & fmt:: Debug ) -> DebugList < ' a , ' b > {
277+ pub fn entry ( & mut self , entry : & fmt:: Debug ) -> & mut DebugList < ' a , ' b > {
271278 self . inner . entry ( entry) ;
272279 self
273280 }
274281
275- /// Consumes the `DebugSet`, finishing output and returning any error
276- /// encountered.
282+ /// Adds the contents of an iterator of entries to the list output.
283+ #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
284+ pub fn entries < D , I > ( & mut self , entries : I ) -> & mut DebugList < ' a , ' b >
285+ where D : fmt:: Debug , I : IntoIterator < Item =D > {
286+ for entry in entries {
287+ self . entry ( & entry) ;
288+ }
289+ self
290+ }
291+
292+ /// Finishes output and returns any error encountered.
277293 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
278- pub fn finish ( mut self ) -> fmt:: Result {
294+ pub fn finish ( & mut self ) -> fmt:: Result {
279295 self . inner . finish ( ) ;
280296 self . inner . result . and_then ( |_| self . inner . fmt . write_str ( "]" ) )
281297 }
@@ -303,7 +319,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
303319impl < ' a , ' b : ' a > DebugMap < ' a , ' b > {
304320 /// Adds a new entry to the map output.
305321 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
306- pub fn entry ( mut self , key : & fmt:: Debug , value : & fmt:: Debug ) -> DebugMap < ' a , ' b > {
322+ pub fn entry ( & mut self , key : & fmt:: Debug , value : & fmt:: Debug ) -> & mut DebugMap < ' a , ' b > {
307323 self . result = self . result . and_then ( |_| {
308324 if self . is_pretty ( ) {
309325 let mut writer = PadAdapter :: new ( self . fmt ) ;
@@ -319,10 +335,19 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
319335 self
320336 }
321337
322- /// Consumes the `DebugMap`, finishing output and returning any error
323- /// encountered.
338+ /// Adds the contents of an iterator of entries to the map output.
339+ #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
340+ pub fn entries < K , V , I > ( & mut self , entries : I ) -> & mut DebugMap < ' a , ' b >
341+ where K : fmt:: Debug , V : fmt:: Debug , I : IntoIterator < Item =( K , V ) > {
342+ for ( k, v) in entries {
343+ self . entry ( & k, & v) ;
344+ }
345+ self
346+ }
347+
348+ /// Finishes output and returns any error encountered.
324349 #[ unstable( feature = "debug_builders" , reason = "method was just created" ) ]
325- pub fn finish ( self ) -> fmt:: Result {
350+ pub fn finish ( & mut self ) -> fmt:: Result {
326351 let prefix = if self . is_pretty ( ) && self . has_fields { "\n " } else { "" } ;
327352 self . result . and_then ( |_| write ! ( self . fmt, "{}}}" , prefix) )
328353 }
0 commit comments