Skip to content

Commit 70fa1fb

Browse files
committed
Added a StableHasherResult impl for u128.
1 parent 60ac9f4 commit 70fa1fb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/librustc_data_structures/stable_hasher.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ impl StableHasherResult for [u8; 20] {
7878
}
7979
}
8080

81+
impl StableHasherResult for u128 {
82+
fn finish(mut hasher: StableHasher<Self>) -> Self {
83+
let hash_bytes: &[u8] = hasher.finalize();
84+
assert!(hash_bytes.len() >= mem::size_of::<u64>() * 2);
85+
86+
unsafe {
87+
::std::ptr::read_unaligned(hash_bytes.as_ptr() as *const u128)
88+
}
89+
}
90+
}
91+
8192
impl StableHasherResult for u64 {
8293
fn finish(mut hasher: StableHasher<Self>) -> Self {
8394
hasher.state.finalize();

0 commit comments

Comments
 (0)