[core] Replace for_each with for loop

parent 1b5b002e
Pipeline #98752 passed with stages
in 8 minutes and 38 seconds
......@@ -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(())
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment