Manually implement Debug for BTreeMap::ValuesMut struct
Deriving debug prints all the values including keys. But ValuesMut struct should only print the values.
This commit is contained in:
parent
456738e3d1
commit
c346e89db8
1 changed files with 24 additions and 1 deletions
|
@ -361,11 +361,17 @@ impl<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> {
|
||||||
///
|
///
|
||||||
/// [`values_mut`]: BTreeMap::values_mut
|
/// [`values_mut`]: BTreeMap::values_mut
|
||||||
#[stable(feature = "map_values_mut", since = "1.10.0")]
|
#[stable(feature = "map_values_mut", since = "1.10.0")]
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ValuesMut<'a, K: 'a, V: 'a> {
|
pub struct ValuesMut<'a, K: 'a, V: 'a> {
|
||||||
inner: IterMut<'a, K, V>,
|
inner: IterMut<'a, K, V>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "map_values_mut", since = "1.10.0")]
|
||||||
|
impl<K, V: fmt::Debug> fmt::Debug for ValuesMut<'_, K, V> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_list().entries(self.inner.iter().map(|(_, val)| val)).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An owning iterator over the keys of a `BTreeMap`.
|
/// An owning iterator over the keys of a `BTreeMap`.
|
||||||
///
|
///
|
||||||
/// This `struct` is created by the [`into_keys`] method on [`BTreeMap`].
|
/// This `struct` is created by the [`into_keys`] method on [`BTreeMap`].
|
||||||
|
@ -1519,6 +1525,14 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
|
||||||
#[stable(feature = "fused", since = "1.26.0")]
|
#[stable(feature = "fused", since = "1.26.0")]
|
||||||
impl<K, V> FusedIterator for IterMut<'_, K, V> {}
|
impl<K, V> FusedIterator for IterMut<'_, K, V> {}
|
||||||
|
|
||||||
|
impl<'a, K, V> IterMut<'a, K, V> {
|
||||||
|
/// Returns an iterator of references over the remaining items.
|
||||||
|
#[inline]
|
||||||
|
pub(super) fn iter(&self) -> Iter<'_, K, V> {
|
||||||
|
Iter { range: self.range.iter(), length: self.length }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<K, V> IntoIterator for BTreeMap<K, V> {
|
impl<K, V> IntoIterator for BTreeMap<K, V> {
|
||||||
type Item = (K, V);
|
type Item = (K, V);
|
||||||
|
@ -2006,6 +2020,15 @@ impl<'a, K, V> RangeMut<'a, K, V> {
|
||||||
unsafe fn next_unchecked(&mut self) -> (&'a mut K, &'a mut V) {
|
unsafe fn next_unchecked(&mut self) -> (&'a mut K, &'a mut V) {
|
||||||
unsafe { unwrap_unchecked(self.front.as_mut()).next_unchecked() }
|
unsafe { unwrap_unchecked(self.front.as_mut()).next_unchecked() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an iterator of references over the remaining items.
|
||||||
|
#[inline]
|
||||||
|
pub(super) fn iter(&self) -> Range<'_, K, V> {
|
||||||
|
Range {
|
||||||
|
front: self.front.as_ref().map(|f| f.reborrow()),
|
||||||
|
back: self.back.as_ref().map(|b| b.reborrow()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "btree_range", since = "1.17.0")]
|
#[stable(feature = "btree_range", since = "1.17.0")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue