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.
This commit is contained in:
parent
71a15212a1
commit
1b895a8632
|
@ -120,8 +120,9 @@ use std::hash;
|
|||
|
||||
#[cfg(test)]
|
||||
fn hash<T: hash::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 = <RandomState as BuildHasher>::Hasher::new();
|
||||
x.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
|
|
|
@ -765,8 +765,9 @@ impl<T> serde::Deserialize for Complex<T> where
|
|||
|
||||
#[cfg(test)]
|
||||
fn hash<T: hash::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 = <RandomState as BuildHasher>::Hasher::new();
|
||||
x.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
|
|
|
@ -670,8 +670,9 @@ impl RatioErrorKind {
|
|||
|
||||
#[cfg(test)]
|
||||
fn hash<T: hash::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 = <RandomState as BuildHasher>::Hasher::new();
|
||||
x.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue