From 16cadf1a64abf36d43aefa0ce5ee6ad35e15dbab Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 11 Dec 2015 14:40:28 +0100 Subject: [PATCH] hash for uint --- src/uint.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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(); + } + } ); }