Added a `StableHasherResult` impl for `u128`.

This commit is contained in:
Inokentiy Babushkin 2017-06-10 12:21:24 +02:00
parent 60ac9f467c
commit 70fa1fbea7
No known key found for this signature in database
GPG Key ID: 7EFC8EC5224DE8EC
1 changed files with 11 additions and 0 deletions

View File

@ -78,6 +78,17 @@ impl StableHasherResult for [u8; 20] {
}
}
impl StableHasherResult for u128 {
fn finish(mut hasher: StableHasher<Self>) -> Self {
let hash_bytes: &[u8] = hasher.finalize();
assert!(hash_bytes.len() >= mem::size_of::<u64>() * 2);
unsafe {
::std::ptr::read_unaligned(hash_bytes.as_ptr() as *const u128)
}
}
}
impl StableHasherResult for u64 {
fn finish(mut hasher: StableHasher<Self>) -> Self {
hasher.state.finalize();