about summary refs log tree commit diff
diff options
context:
space:
mode:
authorInokentiy Babushkin <twk@twki.de>2017-06-10 12:21:24 +0200
committerInokentiy Babushkin <twk@twki.de>2017-06-10 12:21:24 +0200
commit70fa1fbea7786425471b0d43aae320920fd4e917 (patch)
tree573c2cf0a3c93f756762bc17e833d897a26a92d6
parent60ac9f467cbbf8481a6f09e3e90e470dec85cf65 (diff)
downloadrust-70fa1fbea7786425471b0d43aae320920fd4e917.tar.gz
rust-70fa1fbea7786425471b0d43aae320920fd4e917.zip
Added a `StableHasherResult` impl for `u128`.
-rw-r--r--src/librustc_data_structures/stable_hasher.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs
index 634d3041bf4..f3572d3e25b 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>) -> 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();