@@ -47,8 +47,8 @@ fn count_collection_iterator(collection: &[HashMap<String, Progress>], value: Pr
47
47
. sum ( )
48
48
}
49
49
50
- // Equivalent to `count_collection_iterator`+ `count_iterator`, iterating as if
51
- // the collection was a single container instead of a container of containers
50
+ // Equivalent to `count_collection_iterator` and `count_iterator`, iterating as
51
+ // if the collection was a single container instead of a container of containers
52
52
// (and more accurately, a single iterator instead of an iterator of iterators).
53
53
fn count_collection_iterator_flat (
54
54
collection : & [ HashMap < String , Progress > ] ,
@@ -71,10 +71,9 @@ fn main() {
71
71
#[ cfg( test) ]
72
72
mod tests {
73
73
use super :: * ;
74
+ use Progress :: * ;
74
75
75
76
fn get_map ( ) -> HashMap < String , Progress > {
76
- use Progress :: * ;
77
-
78
77
let mut map = HashMap :: new ( ) ;
79
78
map. insert ( String :: from ( "variables1" ) , Complete ) ;
80
79
map. insert ( String :: from ( "functions1" ) , Complete ) ;
@@ -87,8 +86,6 @@ mod tests {
87
86
}
88
87
89
88
fn get_vec_map ( ) -> Vec < HashMap < String , Progress > > {
90
- use Progress :: * ;
91
-
92
89
let map = get_map ( ) ;
93
90
94
91
let mut other = HashMap :: new ( ) ;
@@ -104,25 +101,25 @@ mod tests {
104
101
#[ test]
105
102
fn count_complete ( ) {
106
103
let map = get_map ( ) ;
107
- assert_eq ! ( count_iterator( & map, Progress :: Complete ) , 3 ) ;
104
+ assert_eq ! ( count_iterator( & map, Complete ) , 3 ) ;
108
105
}
109
106
110
107
#[ test]
111
108
fn count_some ( ) {
112
109
let map = get_map ( ) ;
113
- assert_eq ! ( count_iterator( & map, Progress :: Some ) , 1 ) ;
110
+ assert_eq ! ( count_iterator( & map, Some ) , 1 ) ;
114
111
}
115
112
116
113
#[ test]
117
114
fn count_none ( ) {
118
115
let map = get_map ( ) ;
119
- assert_eq ! ( count_iterator( & map, Progress :: None ) , 2 ) ;
116
+ assert_eq ! ( count_iterator( & map, None ) , 2 ) ;
120
117
}
121
118
122
119
#[ test]
123
120
fn count_complete_equals_for ( ) {
124
121
let map = get_map ( ) ;
125
- let progress_states = [ Progress :: Complete , Progress :: Some , Progress :: None ] ;
122
+ let progress_states = [ Complete , Some , None ] ;
126
123
for progress_state in progress_states {
127
124
assert_eq ! (
128
125
count_for( & map, progress_state) ,
@@ -134,40 +131,28 @@ mod tests {
134
131
#[ test]
135
132
fn count_collection_complete ( ) {
136
133
let collection = get_vec_map ( ) ;
137
- assert_eq ! (
138
- count_collection_iterator( & collection, Progress :: Complete ) ,
139
- 6 ,
140
- ) ;
141
- assert_eq ! (
142
- count_collection_iterator_flat( & collection, Progress :: Complete ) ,
143
- 6 ,
144
- ) ;
134
+ assert_eq ! ( count_collection_iterator( & collection, Complete ) , 6 ) ;
135
+ assert_eq ! ( count_collection_iterator_flat( & collection, Complete ) , 6 ) ;
145
136
}
146
137
147
138
#[ test]
148
139
fn count_collection_some ( ) {
149
140
let collection = get_vec_map ( ) ;
150
- assert_eq ! ( count_collection_iterator( & collection, Progress :: Some ) , 1 ) ;
151
- assert_eq ! (
152
- count_collection_iterator_flat( & collection, Progress :: Some ) ,
153
- 1
154
- ) ;
141
+ assert_eq ! ( count_collection_iterator( & collection, Some ) , 1 ) ;
142
+ assert_eq ! ( count_collection_iterator_flat( & collection, Some ) , 1 ) ;
155
143
}
156
144
157
145
#[ test]
158
146
fn count_collection_none ( ) {
159
147
let collection = get_vec_map ( ) ;
160
- assert_eq ! ( count_collection_iterator( & collection, Progress :: None ) , 4 ) ;
161
- assert_eq ! (
162
- count_collection_iterator_flat( & collection, Progress :: None ) ,
163
- 4
164
- ) ;
148
+ assert_eq ! ( count_collection_iterator( & collection, None ) , 4 ) ;
149
+ assert_eq ! ( count_collection_iterator_flat( & collection, None ) , 4 ) ;
165
150
}
166
151
167
152
#[ test]
168
153
fn count_collection_equals_for ( ) {
169
154
let collection = get_vec_map ( ) ;
170
- let progress_states = [ Progress :: Complete , Progress :: Some , Progress :: None ] ;
155
+ let progress_states = [ Complete , Some , None ] ;
171
156
172
157
for progress_state in progress_states {
173
158
assert_eq ! (
0 commit comments