Merge pull request #16 from gavofyork/hash_changes

added H264 (required for extras_db slices), removed unnecessary unsafe code
This commit is contained in:
Gav Wood 2015-12-13 23:17:05 +01:00
commit d88c4db470

View File

@ -43,19 +43,17 @@ macro_rules! impl_hash {
impl Deref for $from { impl Deref for $from {
type Target = [u8]; type Target = [u8];
#[inline] #[inline]
fn deref(&self) -> &[u8] { fn deref(&self) -> &[u8] {
unsafe { &self.0
::std::slice::from_raw_parts(self.0.as_ptr(), $size)
}
} }
} }
impl DerefMut for $from { impl DerefMut for $from {
#[inline] #[inline]
fn deref_mut(&mut self) -> &mut [u8] { fn deref_mut(&mut self) -> &mut [u8] {
unsafe { &mut self.0
::std::slice::from_raw_parts_mut(self.0.as_mut_ptr(), $size)
}
} }
} }
@ -327,6 +325,7 @@ impl_hash!(H64, 8);
impl_hash!(H128, 16); impl_hash!(H128, 16);
impl_hash!(Address, 20); impl_hash!(Address, 20);
impl_hash!(H256, 32); impl_hash!(H256, 32);
impl_hash!(H264, 33);
impl_hash!(H512, 64); impl_hash!(H512, 64);
impl_hash!(H520, 65); impl_hash!(H520, 65);
impl_hash!(H1024, 128); impl_hash!(H1024, 128);