Skip to content

Commit e6f6d26

Browse files
committed
Import enum variants in all tests
1 parent 67d8d58 commit e6f6d26

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

solutions/18_iterators/iterators5.rs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ fn count_collection_iterator(collection: &[HashMap<String, Progress>], value: Pr
4747
.sum()
4848
}
4949

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
5252
// (and more accurately, a single iterator instead of an iterator of iterators).
5353
fn count_collection_iterator_flat(
5454
collection: &[HashMap<String, Progress>],
@@ -71,10 +71,9 @@ fn main() {
7171
#[cfg(test)]
7272
mod tests {
7373
use super::*;
74+
use Progress::*;
7475

7576
fn get_map() -> HashMap<String, Progress> {
76-
use Progress::*;
77-
7877
let mut map = HashMap::new();
7978
map.insert(String::from("variables1"), Complete);
8079
map.insert(String::from("functions1"), Complete);
@@ -87,8 +86,6 @@ mod tests {
8786
}
8887

8988
fn get_vec_map() -> Vec<HashMap<String, Progress>> {
90-
use Progress::*;
91-
9289
let map = get_map();
9390

9491
let mut other = HashMap::new();
@@ -104,25 +101,25 @@ mod tests {
104101
#[test]
105102
fn count_complete() {
106103
let map = get_map();
107-
assert_eq!(count_iterator(&map, Progress::Complete), 3);
104+
assert_eq!(count_iterator(&map, Complete), 3);
108105
}
109106

110107
#[test]
111108
fn count_some() {
112109
let map = get_map();
113-
assert_eq!(count_iterator(&map, Progress::Some), 1);
110+
assert_eq!(count_iterator(&map, Some), 1);
114111
}
115112

116113
#[test]
117114
fn count_none() {
118115
let map = get_map();
119-
assert_eq!(count_iterator(&map, Progress::None), 2);
116+
assert_eq!(count_iterator(&map, None), 2);
120117
}
121118

122119
#[test]
123120
fn count_complete_equals_for() {
124121
let map = get_map();
125-
let progress_states = [Progress::Complete, Progress::Some, Progress::None];
122+
let progress_states = [Complete, Some, None];
126123
for progress_state in progress_states {
127124
assert_eq!(
128125
count_for(&map, progress_state),
@@ -134,40 +131,28 @@ mod tests {
134131
#[test]
135132
fn count_collection_complete() {
136133
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);
145136
}
146137

147138
#[test]
148139
fn count_collection_some() {
149140
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);
155143
}
156144

157145
#[test]
158146
fn count_collection_none() {
159147
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);
165150
}
166151

167152
#[test]
168153
fn count_collection_equals_for() {
169154
let collection = get_vec_map();
170-
let progress_states = [Progress::Complete, Progress::Some, Progress::None];
155+
let progress_states = [Complete, Some, None];
171156

172157
for progress_state in progress_states {
173158
assert_eq!(

0 commit comments

Comments
 (0)