Skip to content

Commit 5509bb1

Browse files
committed
Improve code readability of a test
1 parent 5027575 commit 5509bb1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/set.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
use hashbrown::HashSet;
44
use rand::{distributions::Alphanumeric, rngs::SmallRng, Rng, SeedableRng};
5+
use std::iter;
56

67
#[test]
78
fn test_hashset_insert_remove() {
89
let mut m: HashSet<Vec<char>> = HashSet::new();
9-
//let num: u32 = 4096;
10-
//let tx: Vec<Vec<u8>> = (0..num).map(|i| (i..(16 + i)).collect()).collect();
10+
1111
let seed: [u8; 16] = [
1212
130, 220, 246, 217, 111, 124, 221, 189, 190, 234, 121, 93, 67, 95, 100, 43,
1313
];
1414

1515
let rng = &mut SmallRng::from_seed(seed);
16-
let tx: Vec<Vec<char>> = (0..4096)
17-
.map(|_| (rng.sample_iter(&Alphanumeric).take(32).collect()))
18-
.collect();
16+
let tx: Vec<Vec<char>> =
17+
iter::repeat_with(|| rng.sample_iter(&Alphanumeric).take(32).collect())
18+
.take(4096)
19+
.collect();
1920

2021
// more readable with explicit `true` / `false`
2122
#[allow(clippy::bool_assert_comparison)]

0 commit comments

Comments
 (0)