File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -520,7 +520,10 @@ pub trait BuildHasher {
520
520
/// );
521
521
/// ```
522
522
#[ 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
+ {
524
527
let mut hasher = self . build_hasher ( ) ;
525
528
x. hash ( & mut hasher) ;
526
529
hasher. finish ( )
Original file line number Diff line number Diff line change 1
1
mod sip;
2
2
3
3
use std:: default:: Default ;
4
- use std:: hash:: { Hash , Hasher } ;
4
+ use std:: hash:: { BuildHasher , Hash , Hasher } ;
5
5
use std:: rc:: Rc ;
6
6
7
7
struct MyHasher {
@@ -139,3 +139,10 @@ fn test_indirect_hasher() {
139
139
}
140
140
assert_eq ! ( hasher. hash, 5 ) ;
141
141
}
142
+
143
+ #[ test]
144
+ fn test_build_hasher_object_safe ( ) {
145
+ use std:: collections:: hash_map:: { DefaultHasher , RandomState } ;
146
+
147
+ let _: & dyn BuildHasher < Hasher = DefaultHasher > = & RandomState :: new ( ) ;
148
+ }
You can’t perform that action at this time.
0 commit comments