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 1
1
use crate :: { smallvec, SmallVec } ;
2
2
3
+ use core:: hash:: Hasher ;
3
4
use core:: iter:: FromIterator ;
4
5
5
6
use alloc:: borrow:: ToOwned ;
@@ -600,19 +601,24 @@ fn test_hash() {
600
601
use std:: collections:: hash_map:: DefaultHasher ;
601
602
use std:: hash:: Hash ;
602
603
604
+ fn hash ( value : impl Hash ) -> u64 {
605
+ let mut hasher = DefaultHasher :: new ( ) ;
606
+ value. hash ( & mut hasher) ;
607
+ hasher. finish ( )
608
+ }
609
+
603
610
{
604
611
let mut a: SmallVec < u32 , 2 > = SmallVec :: new ( ) ;
605
612
let b = [ 1 , 2 ] ;
606
613
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) ) ;
609
615
}
616
+
610
617
{
611
618
let mut a: SmallVec < u32 , 2 > = SmallVec :: new ( ) ;
612
619
let b = [ 1 , 2 , 11 , 12 ] ;
613
620
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) ) ;
616
622
}
617
623
}
618
624
You can’t perform that action at this time.
0 commit comments