From a10c385f2f062604a489b663a71162e923c6be08 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Mon, 3 Jul 2023 14:01:06 -0400 Subject: [PATCH] uefi-raw: Derive Ord, PartialOrd, and Hash for all newtype enums --- uefi-raw/src/enums.rs | 6 +++--- uefi-raw/src/table/boot.rs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/uefi-raw/src/enums.rs b/uefi-raw/src/enums.rs index ae9106dfa..6bea8908f 100644 --- a/uefi-raw/src/enums.rs +++ b/uefi-raw/src/enums.rs @@ -18,8 +18,8 @@ /// /// This macro implements Debug for you, the way you would expect it to work on /// Rust enums (printing the variant name instead of its integer value). It also -/// derives Clone, Copy, Eq and PartialEq, since that always makes sense for -/// C-style enums and is used by the implementation. If you want anything else +/// derives Clone, Copy, Eq, PartialEq, Ord, PartialOrd, and Hash, since those +/// always make sense for C-style enums. If you want anything else /// to be derived, you can ask for it by adding extra derives as shown in the /// example below. /// @@ -53,7 +53,7 @@ macro_rules! newtype_enum { ) => { $(#[$type_attrs])* #[repr(transparent)] - #[derive(Clone, Copy, Eq, PartialEq)] + #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] $visibility struct $type(pub $base_integer); $(#[$impl_attrs])* diff --git a/uefi-raw/src/table/boot.rs b/uefi-raw/src/table/boot.rs index 224902749..0c3ecbc5a 100644 --- a/uefi-raw/src/table/boot.rs +++ b/uefi-raw/src/table/boot.rs @@ -348,7 +348,6 @@ newtype_enum! { /// in the 0x70000000..0xFFFFFFFF range. Therefore, we don't know the full set /// of memory types at compile time, and it is _not_ safe to model this C enum /// as a Rust enum. -#[derive(PartialOrd, Ord, Hash)] pub enum MemoryType: u32 => { /// This enum variant is not used. RESERVED = 0,