summaryrefslogtreecommitdiff
path: root/rust/kernel/pci/id.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/pci/id.rs')
-rw-r--r--rust/kernel/pci/id.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs
index 8ee1dc5c3057..6e081de30faf 100644
--- a/rust/kernel/pci/id.rs
+++ b/rust/kernel/pci/id.rs
@@ -50,6 +50,17 @@ macro_rules! define_all_pci_classes {
pub const $variant: Self = Self(Self::to_24bit_class($binding));
)+
}
+
+ impl fmt::Display for Class {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ $(
+ &Self::$variant => write!(f, stringify!($variant)),
+ )+
+ _ => <Self as fmt::Debug>::fmt(self, f),
+ }
+ }
+ }
};
}
@@ -87,12 +98,6 @@ impl fmt::Debug for Class {
}
}
-impl fmt::Display for Class {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- <Self as fmt::Debug>::fmt(self, f)
- }
-}
-
impl ClassMask {
/// Get the raw mask value.
#[inline]