From f08c8bbf9f180283490fc7a4e116e8fa0ffcc681 Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 11 Feb 2020 00:12:45 -0800 Subject: derive Ord and PartialOrd for RegSpec and RegisterBank this makes these usable as keys in collections such as BTreeMap. there is no specific ordering imposed by Ord (f.ex it may be the case that `eax > dx` while `eax > rax`), but some specific ordering may be imposed in the future. --- src/long_mode/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/long_mode') diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index be2dbeb..099cc47 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -6,13 +6,13 @@ use core::hint::unreachable_unchecked; use yaxpeax_arch::{Decoder, LengthedInstruction}; #[cfg(feature="use-serde")] -#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)] pub struct RegSpec { pub num: u8, pub bank: RegisterBank } #[cfg(not(feature="use-serde"))] -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, PartialOrd, Ord, Eq, PartialEq)] pub struct RegSpec { pub num: u8, pub bank: RegisterBank @@ -364,7 +364,7 @@ fn operand_size() { #[allow(non_camel_case_types)] #[cfg(feature="use-serde")] -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)] pub enum RegisterBank { Q, D, W, B, rB, // Quadword, Dword, Word, Byte CR, DR, S, EIP, RIP, EFlags, RFlags, // Control reg, Debug reg, Selector, ... @@ -374,7 +374,7 @@ pub enum RegisterBank { } #[allow(non_camel_case_types)] #[cfg(not(feature="use-serde"))] -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] pub enum RegisterBank { Q, D, W, B, rB, // Quadword, Dword, Word, Byte CR, DR, S, EIP, RIP, EFlags, RFlags, // Control reg, Debug reg, Selector, ... -- cgit v1.1