From::from(u64) for hashes.
This commit is contained in:
parent
4be539a965
commit
dd99ebd859
13
src/hash.rs
13
src/hash.rs
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user