From e324acc29f839eccf976906720c1e7796a9adb49 Mon Sep 17 00:00:00 2001 From: David Li Date: Thu, 14 Jan 2016 11:44:56 -0700 Subject: Implement Hash, Display for IsaTypes --- src/isa/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/isa/mod.rs b/src/isa/mod.rs index d5a5c14..8d86610 100644 --- a/src/isa/mod.rs +++ b/src/isa/mod.rs @@ -59,7 +59,7 @@ macro_rules! isa_type_assign_op { macro_rules! isa_type { ($name: ident, $utype: ty) => { - #[derive(Clone,Copy,Debug,Eq,Ord,PartialEq,PartialOrd)] + #[derive(Clone,Copy,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)] pub struct $name(pub $utype); impl $name { @@ -85,6 +85,12 @@ macro_rules! isa_type { isa_type_op!($name, $utype, BitOr, bitor); isa_type_op!($name, $utype, BitXor, bitxor); + impl fmt::Display for $name { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "{}", self.0) + } + } + impl fmt::LowerHex for $name { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(f, "{:x}", self.0) -- cgit v1.2.3