diff options
author | David Li <li.davidm96@gmail.com> | 2016-01-14 11:44:56 -0700 |
---|---|---|
committer | David Li <li.davidm96@gmail.com> | 2016-01-14 11:44:56 -0700 |
commit | e324acc29f839eccf976906720c1e7796a9adb49 (patch) | |
tree | 2d198dfa3ce30d1bfda331f1ae6921d18357b35f /src/isa | |
parent | 97754ba7f51f8cb0c7827b9ee2807a8ffd97fc6e (diff) |
Implement Hash, Display for IsaTypes
Diffstat (limited to 'src/isa')
-rw-r--r-- | src/isa/mod.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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) |