Skip to content

Commit 481b282

Browse files
committed
make BuildHasher object safe
1 parent d0a10b2 commit 481b282

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

library/core/src/hash/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,10 @@ pub trait BuildHasher {
520520
/// );
521521
/// ```
522522
#[unstable(feature = "build_hasher_simple_hash_one", issue = "86161")]
523-
fn hash_one<T: Hash>(&self, x: T) -> u64 {
523+
fn hash_one<T: Hash>(&self, x: T) -> u64
524+
where
525+
Self: Sized,
526+
{
524527
let mut hasher = self.build_hasher();
525528
x.hash(&mut hasher);
526529
hasher.finish()
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// run-pass
2+
3+
use std::hash::BuildHasher;
4+
use std::collections::hash_map::{DefaultHasher, RandomState};
5+
6+
fn ensure_object_safe(_: &dyn BuildHasher<Hasher = DefaultHasher>) {}
7+
8+
fn main() {
9+
ensure_object_safe(&RandomState::new());
10+
}

0 commit comments

Comments
 (0)