make BuildHasher
object safe
This commit is contained in:
parent
d0a10b2056
commit
481b282e8a
|
@ -520,7 +520,10 @@ pub trait BuildHasher {
|
|||
/// );
|
||||
/// ```
|
||||
#[unstable(feature = "build_hasher_simple_hash_one", issue = "86161")]
|
||||
fn hash_one<T: Hash>(&self, x: T) -> u64 {
|
||||
fn hash_one<T: Hash>(&self, x: T) -> u64
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut hasher = self.build_hasher();
|
||||
x.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
|
|
10
src/test/ui/build-hasher-object-safe.rs
Normal file
10
src/test/ui/build-hasher-object-safe.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// run-pass
|
||||
|
||||
use std::hash::BuildHasher;
|
||||
use std::collections::hash_map::{DefaultHasher, RandomState};
|
||||
|
||||
fn ensure_object_safe(_: &dyn BuildHasher<Hasher = DefaultHasher>) {}
|
||||
|
||||
fn main() {
|
||||
ensure_object_safe(&RandomState::new());
|
||||
}
|
Loading…
Reference in a new issue