hash for uint

This commit is contained in:
debris 2015-12-11 14:40:28 +01:00
parent 03a3ebff3f
commit 16cadf1a64
1 changed files with 8 additions and 0 deletions

View File

@ -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<H>(&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();
}
}
);
}