@@ -297,14 +297,23 @@ pub struct IntoIter<K, V> {
297297 length : usize ,
298298}
299299
300- #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
301- impl < K : fmt:: Debug , V : fmt:: Debug > fmt:: Debug for IntoIter < K , V > {
302- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
300+ impl < K , V > IntoIter < K , V > {
301+ /// Returns an iterator of references over the remaining items.
302+ #[ inline]
303+ pub ( super ) fn iter ( & self ) -> Iter < ' _ , K , V > {
303304 let range = Range {
304305 front : self . front . as_ref ( ) . map ( |f| f. reborrow ( ) ) ,
305306 back : self . back . as_ref ( ) . map ( |b| b. reborrow ( ) ) ,
306307 } ;
307- f. debug_list ( ) . entries ( range) . finish ( )
308+
309+ Iter { range : range, length : self . length }
310+ }
311+ }
312+
313+ #[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
314+ impl < K : fmt:: Debug , V : fmt:: Debug > fmt:: Debug for IntoIter < K , V > {
315+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
316+ f. debug_list ( ) . entries ( self . iter ( ) ) . finish ( )
308317 }
309318}
310319
@@ -351,35 +360,53 @@ impl<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> {
351360///
352361/// [`values_mut`]: BTreeMap::values_mut
353362#[ stable( feature = "map_values_mut" , since = "1.10.0" ) ]
354- #[ derive( Debug ) ]
355363pub struct ValuesMut < ' a , K : ' a , V : ' a > {
356364 inner : IterMut < ' a , K , V > ,
357365}
358366
367+ #[ stable( feature = "map_values_mut" , since = "1.10.0" ) ]
368+ impl < K , V : fmt:: Debug > fmt:: Debug for ValuesMut < ' _ , K , V > {
369+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
370+ f. debug_list ( ) . entries ( self . inner . iter ( ) . map ( |( _, val) | val) ) . finish ( )
371+ }
372+ }
373+
359374/// An owning iterator over the keys of a `BTreeMap`.
360375///
361376/// This `struct` is created by the [`into_keys`] method on [`BTreeMap`].
362377/// See its documentation for more.
363378///
364379/// [`into_keys`]: BTreeMap::into_keys
365380#[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
366- #[ derive( Debug ) ]
367381pub struct IntoKeys < K , V > {
368382 inner : IntoIter < K , V > ,
369383}
370384
385+ #[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
386+ impl < K : fmt:: Debug , V > fmt:: Debug for IntoKeys < K , V > {
387+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
388+ f. debug_list ( ) . entries ( self . inner . iter ( ) . map ( |( key, _) | key) ) . finish ( )
389+ }
390+ }
391+
371392/// An owning iterator over the values of a `BTreeMap`.
372393///
373394/// This `struct` is created by the [`into_values`] method on [`BTreeMap`].
374395/// See its documentation for more.
375396///
376397/// [`into_values`]: BTreeMap::into_values
377398#[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
378- #[ derive( Debug ) ]
379399pub struct IntoValues < K , V > {
380400 inner : IntoIter < K , V > ,
381401}
382402
403+ #[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
404+ impl < K , V : fmt:: Debug > fmt:: Debug for IntoValues < K , V > {
405+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
406+ f. debug_list ( ) . entries ( self . inner . iter ( ) . map ( |( _, val) | val) ) . finish ( )
407+ }
408+ }
409+
383410/// An iterator over a sub-range of entries in a `BTreeMap`.
384411///
385412/// This `struct` is created by the [`range`] method on [`BTreeMap`]. See its
@@ -1465,6 +1492,14 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
14651492#[ stable( feature = "fused" , since = "1.26.0" ) ]
14661493impl < K , V > FusedIterator for IterMut < ' _ , K , V > { }
14671494
1495+ impl < ' a , K , V > IterMut < ' a , K , V > {
1496+ /// Returns an iterator of references over the remaining items.
1497+ #[ inline]
1498+ pub ( super ) fn iter ( & self ) -> Iter < ' _ , K , V > {
1499+ Iter { range : self . range . iter ( ) , length : self . length }
1500+ }
1501+ }
1502+
14681503#[ stable( feature = "rust1" , since = "1.0.0" ) ]
14691504impl < K , V > IntoIterator for BTreeMap < K , V > {
14701505 type Item = ( K , V ) ;
@@ -1949,6 +1984,15 @@ impl<'a, K, V> RangeMut<'a, K, V> {
19491984 unsafe fn next_unchecked ( & mut self ) -> ( & ' a K , & ' a mut V ) {
19501985 unsafe { unwrap_unchecked ( self . front . as_mut ( ) ) . next_unchecked ( ) }
19511986 }
1987+
1988+ /// Returns an iterator of references over the remaining items.
1989+ #[ inline]
1990+ pub ( super ) fn iter ( & self ) -> Range < ' _ , K , V > {
1991+ Range {
1992+ front : self . front . as_ref ( ) . map ( |f| f. reborrow ( ) ) ,
1993+ back : self . back . as_ref ( ) . map ( |b| b. reborrow ( ) ) ,
1994+ }
1995+ }
19521996}
19531997
19541998#[ stable( feature = "btree_range" , since = "1.17.0" ) ]
0 commit comments