Ver Fonte

Add `Debug` impl for `PhysicalMapping` even when `T` is not `Debug`

Caleb Robson há 1 ano atrás
pai
commit
616ccc5a25
1 ficheiros alterados com 16 adições e 2 exclusões
  1. 16 2
      acpi/src/handler.rs

+ 16 - 2
acpi/src/handler.rs

@@ -1,11 +1,10 @@
-use core::{ops::Deref, ptr::NonNull};
+use core::{fmt, ops::Deref, ptr::NonNull};
 
 /// Describes a physical mapping created by `AcpiHandler::map_physical_region` and unmapped by
 /// `AcpiHandler::unmap_physical_region`. The region mapped must be at least `size_of::<T>()`
 /// bytes, but may be bigger.
 ///
 /// See `PhysicalMapping::new` for the meaning of each field.
-#[derive(Debug)]
 pub struct PhysicalMapping<H, T>
 where
     H: AcpiHandler,
@@ -17,6 +16,21 @@ where
     handler: H,
 }
 
+impl<H, T> fmt::Debug for PhysicalMapping<H, T>
+where
+    H: AcpiHandler + fmt::Debug,
+{
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.debug_struct("PhysicalMapping")
+            .field("physical_start", &self.physical_start)
+            .field("virtual_start", &self.virtual_start)
+            .field("region_length", &self.region_length)
+            .field("mapped_length", &self.mapped_length)
+            .field("handler", &self.handler)
+            .finish()
+    }
+}
+
 impl<H, T> PhysicalMapping<H, T>
 where
     H: AcpiHandler,