@@ -242,6 +242,7 @@ where
242242 move |x| k. eq ( x. borrow ( ) )
243243}
244244
245+ #[ cfg( not( feature = "nightly" ) ) ]
245246#[ cfg_attr( feature = "inline-more" , inline) ]
246247pub ( crate ) fn make_hash < K , Q , S > ( hash_builder : & S , val : & Q ) -> u64
247248where
@@ -255,6 +256,18 @@ where
255256 state. finish ( )
256257}
257258
259+ #[ cfg( feature = "nightly" ) ]
260+ #[ cfg_attr( feature = "inline-more" , inline) ]
261+ pub ( crate ) fn make_hash < K , Q , S > ( hash_builder : & S , val : & Q ) -> u64
262+ where
263+ K : Borrow < Q > ,
264+ Q : Hash + ?Sized ,
265+ S : BuildHasher ,
266+ {
267+ hash_builder. hash_one ( val)
268+ }
269+
270+ #[ cfg( not( feature = "nightly" ) ) ]
258271#[ cfg_attr( feature = "inline-more" , inline) ]
259272pub ( crate ) fn make_insert_hash < K , S > ( hash_builder : & S , val : & K ) -> u64
260273where
@@ -267,6 +280,16 @@ where
267280 state. finish ( )
268281}
269282
283+ #[ cfg( feature = "nightly" ) ]
284+ #[ cfg_attr( feature = "inline-more" , inline) ]
285+ pub ( crate ) fn make_insert_hash < K , S > ( hash_builder : & S , val : & K ) -> u64
286+ where
287+ K : Hash ,
288+ S : BuildHasher ,
289+ {
290+ hash_builder. hash_one ( val)
291+ }
292+
270293#[ cfg( feature = "ahash" ) ]
271294impl < K , V > HashMap < K , V , DefaultHashBuilder > {
272295 /// Creates an empty `HashMap`.
@@ -4793,8 +4816,6 @@ mod test_map {
47934816 #[ test]
47944817 #[ cfg( feature = "raw" ) ]
47954818 fn test_into_iter_refresh ( ) {
4796- use core:: hash:: { BuildHasher , Hash , Hasher } ;
4797-
47984819 #[ cfg( miri) ]
47994820 const N : usize = 32 ;
48004821 #[ cfg( not( miri) ) ]
@@ -4817,9 +4838,7 @@ mod test_map {
48174838 loop {
48184839 // occasionally remove some elements
48194840 if i < n && rng. gen_bool ( 0.1 ) {
4820- let mut hasher = hash_builder. build_hasher ( ) ;
4821- i. hash ( & mut hasher) ;
4822- let hash_value = hasher. finish ( ) ;
4841+ let hash_value = super :: make_insert_hash ( & hash_builder, & i) ;
48234842
48244843 unsafe {
48254844 let e = map. table . find ( hash_value, |q| q. 0 . eq ( & i) ) ;
0 commit comments