Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[core] Replace for_each with for loop
  • Loading branch information
cmichi committed Jun 30, 2020
commit 0f0cdb412b0a26015bcd1fc724ad4dcafeca47ff
14 changes: 10 additions & 4 deletions core/src/storage2/collections/hashmap/fuzz_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,27 @@ fn removes(xs: Vec<i32>, xth: usize) {
});

// 2) remove every `xth` element of `xs` from the map
xs.iter().enumerate().for_each(|(x, i)| {
for x in 0..xs.len() {
if x % xth == 0 {
let i = xs.get(x).expect(
"x is always in bounds since we iterate over the vec length; qed",
);
assert_eq!(map.take(&i), Some(i * 10));
len -= 1;
}
assert_eq!(map.len(), len);
});
}

// then
// everything else must still be get-able
xs.iter().enumerate().for_each(|(x, i)| {
for x in 0..xs.len() {
if x % xth != 0 {
let i = xs.get(x).expect(
"x is always in bounds since we iterate over the vec length; qed",
);
assert_eq!(map.get(&i), Some(&(i * 10)));
}
});
}

Ok(())
})
Expand Down