diff --git a/src/uint.rs b/src/uint.rs index 234867ea9..389894c68 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -25,6 +25,7 @@ use std::fmt; use std::cmp::*; use std::ops::*; use std::str::FromStr; +use std::hash::{Hash, Hasher}; use rustc_serialize::hex::{FromHex, FromHexError}; macro_rules! impl_map_from { @@ -350,6 +351,13 @@ macro_rules! construct_uint { Ok(()) } } + + impl Hash for $name { + fn hash(&self, state: &mut H) where H: Hasher { + unsafe { state.write(::std::slice::from_raw_parts(self.0.as_ptr() as *mut u8, self.0.len() * 8)); } + state.finish(); + } + } ); }