Skip to content

Commit

Permalink
Implement Debug for map::IntoIter and set::IntoIter
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Feb 20, 2019
1 parent 6476531 commit 33fd850
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ Recent Changes

- 1.1.0

- Implemented ``Clone`` for ``Keys``, ``Values``, ``Iter`` (for map and set),
``Difference``, ``Intersection``, ``SymmetricDifference`` and ``Union``
- Implemented ``Clone`` for ``map::{Iter, Keys, Values}`` and
``set::{Difference, Intersection, Iter, SymmetricDifference, Union}``

- Implemented ``Debug`` for ``Keys``, ``Values``, ``Iter`` (for map and set),
``Entry``, ``Difference``, ``Intersection``, ``SymmetricDifference`` and ``Union``
- Implemented ``Debug`` for ``map::{Entry, IntoIter, Iter, Keys, Values}`` and
``set::{Difference, Intersection, IntoIter, Iter, SymmetricDifference, Union}``

- 1.0.2

Expand Down
7 changes: 7 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,13 @@ impl<K, V> ExactSizeIterator for IntoIter<K, V> {
}
}

impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IntoIter<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()
}
}

/// A draining iterator over the entries of a `IndexMap`.
///
/// This `struct` is created by the [`drain`] method on [`IndexMap`]. See its
Expand Down
7 changes: 7 additions & 0 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ impl<T> ExactSizeIterator for IntoIter<T> {
}
}

impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let iter = self.iter.as_slice().iter().map(Bucket::key_ref);
f.debug_list().entries(iter).finish()
}
}


/// An iterator over the items of a `IndexSet`.
///
Expand Down

0 comments on commit 33fd850

Please sign in to comment.