From 70fa1fbea7786425471b0d43aae320920fd4e917 Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Sat, 10 Jun 2017 12:21:24 +0200 Subject: [PATCH] Added a `StableHasherResult` impl for `u128`. --- src/librustc_data_structures/stable_hasher.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 634d3041bf4a..f3572d3e25b3 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -78,6 +78,17 @@ impl StableHasherResult for [u8; 20] { } } +impl StableHasherResult for u128 { + fn finish(mut hasher: StableHasher) -> Self { + let hash_bytes: &[u8] = hasher.finalize(); + assert!(hash_bytes.len() >= mem::size_of::() * 2); + + unsafe { + ::std::ptr::read_unaligned(hash_bytes.as_ptr() as *const u128) + } + } +} + impl StableHasherResult for u64 { fn finish(mut hasher: StableHasher) -> Self { hasher.state.finalize();