From f299c885e64112c05ab21c8e020e7f07a4b6a348 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 19 Feb 2026 19:32:10 +1100 Subject: [PATCH] feat(lib): implement `Debug` for `PhysicalAddress` Make it consistent with the debug output for `VirtualAddress` Signed-off-by: Anhad Singh --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 521692b6d3..bb6e38cd7f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ pub enum TableKind { } /// Physical memory address -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] #[repr(transparent)] pub struct PhysicalAddress(usize); @@ -44,6 +44,12 @@ impl PhysicalAddress { } } +impl core::fmt::Debug for PhysicalAddress { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "[phys {:#0x}]", self.data()) + } +} + /// Virtual memory address #[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] #[repr(transparent)] @@ -74,6 +80,7 @@ impl VirtualAddress { } } } + impl core::fmt::Debug for VirtualAddress { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "[virt {:#0x}]", self.data())