Skip to content

Commit d5c15a4

Browse files
[parallel-letter-frequency]: Clippy says to use resize or static creation (#998)
* Clippy says to use resize or static creation For cases with identical data, the for loop is not needed * Use static creation
1 parent 46e9e7a commit d5c15a4

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,14 @@ fn test_case_insensitivity() {
6262
#[test]
6363
#[ignore]
6464
fn test_many_empty_lines() {
65-
let mut v = Vec::with_capacity(1000);
66-
for _ in 0..1000 {
67-
v.push("");
68-
}
65+
let v = vec![""; 1000];
6966
assert_eq!(frequency::frequency(&v[..], 4), HashMap::new());
7067
}
7168

7269
#[test]
7370
#[ignore]
7471
fn test_many_times_same_text() {
75-
let mut v = Vec::with_capacity(1000);
76-
for _ in 0..1000 {
77-
v.push("abc");
78-
}
72+
let v = vec!["abc"; 1000];
7973
let mut hm = HashMap::new();
8074
hm.insert('a', 1000);
8175
hm.insert('b', 1000);

0 commit comments

Comments
 (0)