Skip to content

Commit 41cbb62

Browse files
committed
Make ClusterId print nicer.
1 parent b6b5bd5 commit 41cbb62

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/filesystem/cluster.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// A cluster is a consecutive group of blocks. Each cluster has a a numeric ID.
44
/// Some numeric IDs are reserved for special purposes.
55
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
6-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
6+
#[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
77
pub struct ClusterId(pub(crate) u32);
88

99
impl ClusterId {
@@ -33,6 +33,34 @@ impl core::ops::AddAssign<u32> for ClusterId {
3333
}
3434
}
3535

36+
impl core::fmt::Debug for ClusterId {
37+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
38+
write!(f, "ClusterId(")?;
39+
match *self {
40+
Self::INVALID => {
41+
write!(f, "INVALID")?;
42+
}
43+
Self::BAD => {
44+
write!(f, "BAD")?;
45+
}
46+
Self::EMPTY => {
47+
write!(f, "EMPTY")?;
48+
}
49+
Self::ROOT_DIR => {
50+
write!(f, "ROOT_DIR")?;
51+
}
52+
Self::END_OF_FILE => {
53+
write!(f, "END_OF_FILE")?;
54+
}
55+
ClusterId(value) => {
56+
write!(f, "{:#08x}", value)?;
57+
}
58+
}
59+
write!(f, ")")?;
60+
Ok(())
61+
}
62+
}
63+
3664
// ****************************************************************************
3765
//
3866
// End Of File

0 commit comments

Comments
 (0)