From 71a15212a180551afebfb63b6a8a4b466be7c44c Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Fri, 28 Apr 2017 18:48:50 -0700 Subject: [PATCH 1/2] Replace deprecated SipHasher. --- bigint/src/lib.rs | 2 +- complex/src/lib.rs | 2 +- rational/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bigint/src/lib.rs b/bigint/src/lib.rs index 5d261da..de6f223 100644 --- a/bigint/src/lib.rs +++ b/bigint/src/lib.rs @@ -121,7 +121,7 @@ use std::hash; #[cfg(test)] fn hash(x: &T) -> u64 { use std::hash::Hasher; - let mut hasher = hash::SipHasher::new(); + let mut hasher = std::collections::hash_map::DefaultHasher::new(); x.hash(&mut hasher); hasher.finish() } diff --git a/complex/src/lib.rs b/complex/src/lib.rs index c73cb42..339a1f2 100644 --- a/complex/src/lib.rs +++ b/complex/src/lib.rs @@ -766,7 +766,7 @@ impl serde::Deserialize for Complex where #[cfg(test)] fn hash(x: &T) -> u64 { use std::hash::Hasher; - let mut hasher = hash::SipHasher::new(); + let mut hasher = std::collections::hash_map::DefaultHasher::new(); x.hash(&mut hasher); hasher.finish() } diff --git a/rational/src/lib.rs b/rational/src/lib.rs index ce88516..02a17a7 100644 --- a/rational/src/lib.rs +++ b/rational/src/lib.rs @@ -671,7 +671,7 @@ impl RatioErrorKind { #[cfg(test)] fn hash(x: &T) -> u64 { use std::hash::Hasher; - let mut hasher = hash::SipHasher::new(); + let mut hasher = std::collections::hash_map::DefaultHasher::new(); x.hash(&mut hasher); hasher.finish() } From 1b895a8632cf4f30e840a98a5019b1f33f2f1fa3 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 6 May 2017 22:23:31 -0700 Subject: [PATCH 2/2] Get the default hasher indirectly `DefaultHasher` wasn't stable until 1.13, at which point all the other hashers were deprecated, so it's not easy for us to name a hasher type to use for testing. However, `RandomState` has been stable since 1.7, and it implements `BuildHasher` that has a `Hasher` associated type. --- bigint/src/lib.rs | 5 +++-- complex/src/lib.rs | 5 +++-- rational/src/lib.rs | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bigint/src/lib.rs b/bigint/src/lib.rs index de6f223..586eeec 100644 --- a/bigint/src/lib.rs +++ b/bigint/src/lib.rs @@ -120,8 +120,9 @@ use std::hash; #[cfg(test)] fn hash(x: &T) -> u64 { - use std::hash::Hasher; - let mut hasher = std::collections::hash_map::DefaultHasher::new(); + use std::hash::{BuildHasher, Hasher}; + use std::collections::hash_map::RandomState; + let mut hasher = ::Hasher::new(); x.hash(&mut hasher); hasher.finish() } diff --git a/complex/src/lib.rs b/complex/src/lib.rs index 339a1f2..cb605a2 100644 --- a/complex/src/lib.rs +++ b/complex/src/lib.rs @@ -765,8 +765,9 @@ impl serde::Deserialize for Complex where #[cfg(test)] fn hash(x: &T) -> u64 { - use std::hash::Hasher; - let mut hasher = std::collections::hash_map::DefaultHasher::new(); + use std::hash::{BuildHasher, Hasher}; + use std::collections::hash_map::RandomState; + let mut hasher = ::Hasher::new(); x.hash(&mut hasher); hasher.finish() } diff --git a/rational/src/lib.rs b/rational/src/lib.rs index 02a17a7..62b7532 100644 --- a/rational/src/lib.rs +++ b/rational/src/lib.rs @@ -670,8 +670,9 @@ impl RatioErrorKind { #[cfg(test)] fn hash(x: &T) -> u64 { - use std::hash::Hasher; - let mut hasher = std::collections::hash_map::DefaultHasher::new(); + use std::hash::{BuildHasher, Hasher}; + use std::collections::hash_map::RandomState; + let mut hasher = ::Hasher::new(); x.hash(&mut hasher); hasher.finish() }