Skip to content

Commit

Permalink
impl Debug for IterMut and ValuesMut
Browse files Browse the repository at this point in the history
(cherry picked from commit 4ddce3a)
  • Loading branch information
cuviper committed Jun 16, 2022
1 parent 1118bab commit 74b4312
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- The `hashbrown` dependency has been updated to version 0.12.

- `IterMut` and `ValuesMut` now implement `Debug`.

- 1.8.2

- Bump the `rustc-rayon` dependency, for compiler use only.
Expand Down
14 changes: 12 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,12 @@ impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {

impl<K, V> FusedIterator for ValuesMut<'_, K, V> {}

// TODO: `impl Debug for ValuesMut` once we have MSRV 1.53 for `slice::IterMut::as_slice`
impl<K, V: fmt::Debug> fmt::Debug for ValuesMut<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let iter = self.iter.as_slice().iter().map(Bucket::value_ref);
f.debug_list().entries(iter).finish()
}
}

/// An owning iterator over the values of a `IndexMap`.
///
Expand Down Expand Up @@ -1110,7 +1115,12 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {

impl<K, V> FusedIterator for IterMut<'_, K, V> {}

// TODO: `impl Debug for IterMut` once we have MSRV 1.53 for `slice::IterMut::as_slice`
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IterMut<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let iter = self.iter.as_slice().iter().map(Bucket::refs);
f.debug_list().entries(iter).finish()
}
}

/// An owning iterator over the entries of a `IndexMap`.
///
Expand Down

0 comments on commit 74b4312

Please sign in to comment.