@@ -270,8 +270,16 @@ pub struct Iter<'a, K: 'a, V: 'a> {
270270 length : usize ,
271271}
272272
273+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
274+ impl < ' a , K : ' a + fmt:: Debug , V : ' a + fmt:: Debug > fmt:: Debug for Iter < ' a , K , V > {
275+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
276+ f. debug_list ( ) . entries ( self . clone ( ) ) . finish ( )
277+ }
278+ }
279+
273280/// A mutable iterator over a BTreeMap's entries.
274281#[ stable( feature = "rust1" , since = "1.0.0" ) ]
282+ #[ derive( Debug ) ]
275283pub struct IterMut < ' a , K : ' a , V : ' a > {
276284 range : RangeMut < ' a , K , V > ,
277285 length : usize ,
@@ -285,20 +293,46 @@ pub struct IntoIter<K, V> {
285293 length : usize ,
286294}
287295
296+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
297+ impl < K : fmt:: Debug , V : fmt:: Debug > fmt:: Debug for IntoIter < K , V > {
298+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
299+ let range = Range {
300+ front : self . front . reborrow ( ) ,
301+ back : self . back . reborrow ( ) ,
302+ } ;
303+ f. debug_list ( ) . entries ( range) . finish ( )
304+ }
305+ }
306+
288307/// An iterator over a BTreeMap's keys.
289308#[ stable( feature = "rust1" , since = "1.0.0" ) ]
290309pub struct Keys < ' a , K : ' a , V : ' a > {
291310 inner : Iter < ' a , K , V > ,
292311}
293312
313+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
314+ impl < ' a , K : ' a + fmt:: Debug , V : ' a + fmt:: Debug > fmt:: Debug for Keys < ' a , K , V > {
315+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
316+ f. debug_list ( ) . entries ( self . inner . clone ( ) ) . finish ( )
317+ }
318+ }
319+
294320/// An iterator over a BTreeMap's values.
295321#[ stable( feature = "rust1" , since = "1.0.0" ) ]
296322pub struct Values < ' a , K : ' a , V : ' a > {
297323 inner : Iter < ' a , K , V > ,
298324}
299325
326+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
327+ impl < ' a , K : ' a + fmt:: Debug , V : ' a + fmt:: Debug > fmt:: Debug for Values < ' a , K , V > {
328+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
329+ f. debug_list ( ) . entries ( self . inner . clone ( ) ) . finish ( )
330+ }
331+ }
332+
300333/// A mutable iterator over a BTreeMap's values.
301334#[ stable( feature = "map_values_mut" , since = "1.10.0" ) ]
335+ #[ derive( Debug ) ]
302336pub struct ValuesMut < ' a , K : ' a , V : ' a > {
303337 inner : IterMut < ' a , K , V > ,
304338}
@@ -309,6 +343,13 @@ pub struct Range<'a, K: 'a, V: 'a> {
309343 back : Handle < NodeRef < marker:: Immut < ' a > , K , V , marker:: Leaf > , marker:: Edge > ,
310344}
311345
346+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
347+ impl < ' a , K : ' a + fmt:: Debug , V : ' a + fmt:: Debug > fmt:: Debug for Range < ' a , K , V > {
348+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
349+ f. debug_list ( ) . entries ( self . clone ( ) ) . finish ( )
350+ }
351+ }
352+
312353/// A mutable iterator over a sub-range of BTreeMap's entries.
313354pub struct RangeMut < ' a , K : ' a , V : ' a > {
314355 front : Handle < NodeRef < marker:: Mut < ' a > , K , V , marker:: Leaf > , marker:: Edge > ,
@@ -318,6 +359,17 @@ pub struct RangeMut<'a, K: 'a, V: 'a> {
318359 _marker : PhantomData < & ' a mut ( K , V ) > ,
319360}
320361
362+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
363+ impl < ' a , K : ' a + fmt:: Debug , V : ' a + fmt:: Debug > fmt:: Debug for RangeMut < ' a , K , V > {
364+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
365+ let range = Range {
366+ front : self . front . reborrow ( ) ,
367+ back : self . back . reborrow ( ) ,
368+ } ;
369+ f. debug_list ( ) . entries ( range) . finish ( )
370+ }
371+ }
372+
321373/// A view into a single entry in a map, which may either be vacant or occupied.
322374/// This enum is constructed from the [`entry`] method on [`BTreeMap`].
323375///
0 commit comments