Auto merge of #291 - cuviper:hasher, r=cuviper
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. (extends #287)
This commit is contained in:
commit
ef752e4687
|
@ -120,8 +120,9 @@ use std::hash;
|
|||
|
||||
#[cfg(test)]
|
||||
fn hash<T: hash::Hash>(x: &T) -> u64 {
|
||||
use std::hash::Hasher;
|
||||
let mut hasher = hash::SipHasher::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 = hash::SipHasher::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()
|
||||
}
|
||||
|
|
|
@ -843,8 +843,9 @@ fn approximate_float_unsigned<T, F>(val: F, max_error: F, max_iterations: usize)
|
|||
|
||||
#[cfg(test)]
|
||||
fn hash<T: hash::Hash>(x: &T) -> u64 {
|
||||
use std::hash::Hasher;
|
||||
let mut hasher = hash::SipHasher::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