Skip to content

Commit 57f9385

Browse files
committed
Implement a better Debug implementation for EntitySet
1 parent 9e6510b commit 57f9385

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cranelift/entity/src/set.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
33
use crate::keys::Keys;
44
use crate::EntityRef;
5+
use core::fmt;
56
use core::marker::PhantomData;
67
use cranelift_bitset::CompoundBitSet;
78

89
/// A set of `K` for densely indexed entity references.
910
///
1011
/// The `EntitySet` data structure uses the dense index space to implement a set with a bitvector.
1112
/// Like `SecondaryMap`, an `EntitySet` is used to associate secondary information with entities.
12-
#[derive(Debug, Clone, PartialEq, Eq)]
13+
#[derive(Clone, PartialEq, Eq)]
1314
#[cfg_attr(
1415
feature = "enable-serde",
1516
derive(serde_derive::Serialize, serde_derive::Deserialize)
@@ -22,6 +23,15 @@ where
2223
unused: PhantomData<K>,
2324
}
2425

26+
impl<K: fmt::Debug> fmt::Debug for EntitySet<K>
27+
where
28+
K: EntityRef,
29+
{
30+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31+
f.debug_set().entries(self.keys()).finish()
32+
}
33+
}
34+
2535
impl<K: EntityRef> Default for EntitySet<K> {
2636
fn default() -> Self {
2737
Self {

0 commit comments

Comments
 (0)