@@ -2,8 +2,20 @@ mod particles;
2
2
use self :: particles:: { Particle , ParticleVec , ParticleRef } ;
3
3
4
4
5
+ /// Helper function to assert that two iterators (one of SoA and another of AoS) are equal.
6
+ fn eq_its < ' a , I1 , I2 > ( i1 : I1 , i2 : I2 )
7
+ where
8
+ I1 : Iterator < Item = ParticleRef < ' a > > ,
9
+ I2 : Iterator < Item = & ' a Particle > ,
10
+ {
11
+ for ( p1, p2) in i1. zip ( i2) {
12
+ assert_eq ! ( p1. name, & p2. name) ;
13
+ assert_eq ! ( * p1. mass, p2. mass) ;
14
+ }
15
+ }
16
+
5
17
#[ test]
6
- fn test_usize ( ) {
18
+ fn test_vec_usize ( ) {
7
19
let mut aos = Vec :: new ( ) ;
8
20
let mut soa = ParticleVec :: new ( ) ;
9
21
@@ -48,18 +60,8 @@ fn test_usize() {
48
60
assert_eq ! ( soa. get( 0 ) . map( |p| * p. mass) , Some ( particle. mass) ) ;
49
61
}
50
62
51
- fn eq_its < ' a , I1 , I2 > ( i1 : I1 , i2 : I2 )
52
- where
53
- I1 : Iterator < Item = ParticleRef < ' a > > ,
54
- I2 : Iterator < Item = & ' a Particle > ,
55
- {
56
- for ( p1, p2) in i1. zip ( i2) {
57
- assert_eq ! ( * p1. mass, p2. mass) ;
58
- }
59
- }
60
-
61
63
#[ test]
62
- fn test_ranges ( ) {
64
+ fn test_vec_ranges ( ) {
63
65
let mut particles = Vec :: new ( ) ;
64
66
particles. push ( Particle :: new ( String :: from ( "Cl" ) , 1.0 ) ) ;
65
67
particles. push ( Particle :: new ( String :: from ( "Na" ) , 2.0 ) ) ;
0 commit comments