[core] Replace for_each with for loop

parent 0f0cdb41
Pipeline #98798 passed with stages
in 9 minutes and 15 seconds
...@@ -33,7 +33,7 @@ fn insert_and_remove(xs: Vec<i32>, inserts_each: u8) { ...@@ -33,7 +33,7 @@ fn insert_and_remove(xs: Vec<i32>, inserts_each: u8) {
let mut previous_even_x = None; let mut previous_even_x = None;
let inserts_each = inserts_each as i32; let inserts_each = inserts_each as i32;
xs.into_iter().for_each(|x| { for x in 0..xs.len() as i32 {
if x % 2 == 0 { if x % 2 == 0 {
// On even numbers we insert // On even numbers we insert
for key in x..x + inserts_each { for key in x..x + inserts_each {
...@@ -67,7 +67,7 @@ fn insert_and_remove(xs: Vec<i32>, inserts_each: u8) { ...@@ -67,7 +67,7 @@ fn insert_and_remove(xs: Vec<i32>, inserts_each: u8) {
} }
previous_even_x = None; previous_even_x = None;
} }
}); }
} }
#[quickcheck] #[quickcheck]
...@@ -92,11 +92,14 @@ fn removes(xs: Vec<i32>, xth: usize) { ...@@ -92,11 +92,14 @@ fn removes(xs: Vec<i32>, xth: usize) {
// when // when
// 1) insert all // 1) insert all
xs.iter().for_each(|i| { for x in 0..xs.len() {
let i = xs.get(x).expect(
"x is always in bounds since we iterate over the vec length; qed",
);
assert_eq!(map.insert(*i, i * 10), None); assert_eq!(map.insert(*i, i * 10), None);
len += 1; len += 1;
assert_eq!(map.len(), len); assert_eq!(map.len(), len);
}); }
// 2) remove every `xth` element of `xs` from the map // 2) remove every `xth` element of `xs` from the map
for x in 0..xs.len() { for x in 0..xs.len() {
......
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