From::from(u64) for hashes.

This commit is contained in:
Gav Wood 2016-01-13 18:41:33 +01:00
parent 4be539a965
commit dd99ebd859

View File

@ -377,6 +377,19 @@ macro_rules! impl_hash {
pub fn from_bloomed<T>(b: &T) -> Self where T: FixedHash { b.bloom_part($size) }
}
impl From<u64> for $from {
fn from(mut value: u64) -> $from {
let mut ret = $from::new();
for i in 0..8 {
if i < $size {
ret.0[$size - i - 1] = (value & 0xff) as u8;
value >>= 8;
}
}
ret
}
}
}
}