Skip to content

Commit 672d877

Browse files
committed
sparse: add better Debug impl
The default impl shows a bit too many details that aren't usually what you want to see when debugging.
1 parent b490e0b commit 672d877

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/sparse.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt;
12
use std::ops::Deref;
23
use std::slice;
34

@@ -11,7 +12,7 @@ use std::slice;
1112
/// Note though that we don't actually use uninitialized memory. We generally
1213
/// reuse allocations, so the initial allocation cost is bareable. However,
1314
/// its other properties listed above are extremely useful.
14-
#[derive(Clone, Debug)]
15+
#[derive(Clone)]
1516
pub struct SparseSet {
1617
/// Dense contains the instruction pointers in the order in which they
1718
/// were inserted.
@@ -60,6 +61,12 @@ impl SparseSet {
6061
}
6162
}
6263

64+
impl fmt::Debug for SparseSet {
65+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
66+
write!(f, "SparseSet({:?})", self.dense)
67+
}
68+
}
69+
6370
impl Deref for SparseSet {
6471
type Target = [usize];
6572

0 commit comments

Comments
 (0)