@@ -297,14 +297,23 @@ pub struct IntoIter<K, V> {
297
297
length : usize ,
298
298
}
299
299
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 > {
303
304
let range = Range {
304
305
front : self . front . as_ref ( ) . map ( |f| f. reborrow ( ) ) ,
305
306
back : self . back . as_ref ( ) . map ( |b| b. reborrow ( ) ) ,
306
307
} ;
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 ( )
308
317
}
309
318
}
310
319
@@ -351,35 +360,53 @@ impl<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> {
351
360
///
352
361
/// [`values_mut`]: BTreeMap::values_mut
353
362
#[ stable( feature = "map_values_mut" , since = "1.10.0" ) ]
354
- #[ derive( Debug ) ]
355
363
pub struct ValuesMut < ' a , K : ' a , V : ' a > {
356
364
inner : IterMut < ' a , K , V > ,
357
365
}
358
366
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
+
359
374
/// An owning iterator over the keys of a `BTreeMap`.
360
375
///
361
376
/// This `struct` is created by the [`into_keys`] method on [`BTreeMap`].
362
377
/// See its documentation for more.
363
378
///
364
379
/// [`into_keys`]: BTreeMap::into_keys
365
380
#[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
366
- #[ derive( Debug ) ]
367
381
pub struct IntoKeys < K , V > {
368
382
inner : IntoIter < K , V > ,
369
383
}
370
384
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
+
371
392
/// An owning iterator over the values of a `BTreeMap`.
372
393
///
373
394
/// This `struct` is created by the [`into_values`] method on [`BTreeMap`].
374
395
/// See its documentation for more.
375
396
///
376
397
/// [`into_values`]: BTreeMap::into_values
377
398
#[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
378
- #[ derive( Debug ) ]
379
399
pub struct IntoValues < K , V > {
380
400
inner : IntoIter < K , V > ,
381
401
}
382
402
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
+
383
410
/// An iterator over a sub-range of entries in a `BTreeMap`.
384
411
///
385
412
/// This `struct` is created by the [`range`] method on [`BTreeMap`]. See its
@@ -1465,6 +1492,14 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
1465
1492
#[ stable( feature = "fused" , since = "1.26.0" ) ]
1466
1493
impl < K , V > FusedIterator for IterMut < ' _ , K , V > { }
1467
1494
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
+
1468
1503
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1469
1504
impl < K , V > IntoIterator for BTreeMap < K , V > {
1470
1505
type Item = ( K , V ) ;
@@ -1949,6 +1984,15 @@ impl<'a, K, V> RangeMut<'a, K, V> {
1949
1984
unsafe fn next_unchecked ( & mut self ) -> ( & ' a K , & ' a mut V ) {
1950
1985
unsafe { unwrap_unchecked ( self . front . as_mut ( ) ) . next_unchecked ( ) }
1951
1986
}
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
+ }
1952
1996
}
1953
1997
1954
1998
#[ stable( feature = "btree_range" , since = "1.17.0" ) ]
0 commit comments