File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 11use crate :: { smallvec, SmallVec } ;
22
3+ use core:: hash:: Hasher ;
34use core:: iter:: FromIterator ;
45
56use alloc:: borrow:: ToOwned ;
@@ -600,19 +601,24 @@ fn test_hash() {
600601 use std:: collections:: hash_map:: DefaultHasher ;
601602 use std:: hash:: Hash ;
602603
604+ fn hash ( value : impl Hash ) -> u64 {
605+ let mut hasher = DefaultHasher :: new ( ) ;
606+ value. hash ( & mut hasher) ;
607+ hasher. finish ( )
608+ }
609+
603610 {
604611 let mut a: SmallVec < u32 , 2 > = SmallVec :: new ( ) ;
605612 let b = [ 1 , 2 ] ;
606613 a. extend ( b. iter ( ) . cloned ( ) ) ;
607- let mut hasher = DefaultHasher :: new ( ) ;
608- assert_eq ! ( a. hash( & mut hasher) , b. hash( & mut hasher) ) ;
614+ assert_eq ! ( hash( a) , hash( b) ) ;
609615 }
616+
610617 {
611618 let mut a: SmallVec < u32 , 2 > = SmallVec :: new ( ) ;
612619 let b = [ 1 , 2 , 11 , 12 ] ;
613620 a. extend ( b. iter ( ) . cloned ( ) ) ;
614- let mut hasher = DefaultHasher :: new ( ) ;
615- assert_eq ! ( a. hash( & mut hasher) , b. hash( & mut hasher) ) ;
621+ assert_eq ! ( hash( a) , hash( b) ) ;
616622 }
617623}
618624
You can’t perform that action at this time.
0 commit comments