diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index 58b5fa2a1..75a6942ae 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -304,8 +304,8 @@ fn make_create_message( instructions }) + .flatten() .collect(); - let instructions: Vec<_> = instructions.into_iter().flatten().collect(); Message::new(&instructions, Some(&keypair.pubkey())) } diff --git a/core/src/heaviest_subtree_fork_choice.rs b/core/src/heaviest_subtree_fork_choice.rs index 4765a70cf..59d66256b 100644 --- a/core/src/heaviest_subtree_fork_choice.rs +++ b/core/src/heaviest_subtree_fork_choice.rs @@ -1204,10 +1204,10 @@ mod test { .map(|s| (s, Hash::default())) .collect::>() ); - let parents: Vec<_> = heaviest_subtree_fork_choice + assert!(heaviest_subtree_fork_choice .ancestor_iterator((0, Hash::default())) - .collect(); - assert!(parents.is_empty()); + .next() + .is_none()); // Set a root, everything but slots 2, 4 should be removed heaviest_subtree_fork_choice.set_root((2, Hash::default())); @@ -1555,11 +1555,8 @@ mod test { .add_new_leaf_slot((10, Hash::default()), Some((4, Hash::default()))); let ancestors = heaviest_subtree_fork_choice .ancestor_iterator((10, Hash::default())) - .collect::>(); - for a in ancestors - .into_iter() - .chain(std::iter::once((10, Hash::default()))) - { + .chain(std::iter::once((10, Hash::default()))); + for a in ancestors { assert_eq!(heaviest_subtree_fork_choice.best_slot(&a).unwrap().0, 10); } @@ -1568,11 +1565,8 @@ mod test { .add_new_leaf_slot((9, Hash::default()), Some((4, Hash::default()))); let ancestors = heaviest_subtree_fork_choice .ancestor_iterator((9, Hash::default())) - .collect::>(); - for a in ancestors - .into_iter() - .chain(std::iter::once((9, Hash::default()))) - { + .chain(std::iter::once((9, Hash::default()))); + for a in ancestors { assert_eq!(heaviest_subtree_fork_choice.best_slot(&a).unwrap().0, 9); } @@ -1581,11 +1575,8 @@ mod test { .add_new_leaf_slot((11, Hash::default()), Some((4, Hash::default()))); let ancestors = heaviest_subtree_fork_choice .ancestor_iterator((11, Hash::default())) - .collect::>(); - for a in ancestors - .into_iter() - .chain(std::iter::once((9, Hash::default()))) - { + .chain(std::iter::once((9, Hash::default()))); + for a in ancestors { assert_eq!(heaviest_subtree_fork_choice.best_slot(&a).unwrap().0, 9); } @@ -1608,11 +1599,8 @@ mod test { .add_new_leaf_slot((8, Hash::default()), Some((4, Hash::default()))); let ancestors = heaviest_subtree_fork_choice .ancestor_iterator((8, Hash::default())) - .collect::>(); - for a in ancestors - .into_iter() - .chain(std::iter::once((8, Hash::default()))) - { + .chain(std::iter::once((8, Hash::default()))); + for a in ancestors { let best_slot = if a.0 > 1 { 8 } else { leaf6 }; assert_eq!( heaviest_subtree_fork_choice.best_slot(&a).unwrap().0, @@ -1635,11 +1623,8 @@ mod test { .add_new_leaf_slot((7, Hash::default()), Some((4, Hash::default()))); let ancestors = heaviest_subtree_fork_choice .ancestor_iterator((7, Hash::default())) - .collect::>(); - for a in ancestors - .into_iter() - .chain(std::iter::once((8, Hash::default()))) - { + .chain(std::iter::once((8, Hash::default()))); + for a in ancestors { assert_eq!(heaviest_subtree_fork_choice.best_slot(&a).unwrap().0, 8); } diff --git a/runtime/src/accounts_hash.rs b/runtime/src/accounts_hash.rs index a5827dd21..f32208bf8 100644 --- a/runtime/src/accounts_hash.rs +++ b/runtime/src/accounts_hash.rs @@ -1490,8 +1490,7 @@ pub mod tests { let input: Vec> = vec![vec![]]; let cumulative = CumulativeOffsets::from_raw(&input); - let src: Vec<_> = input.into_iter().flatten().collect(); - let len = src.len(); + let len = input.into_iter().flatten().count(); assert_eq!(cumulative.total_count, len); assert_eq!(cumulative.cumulative_offsets.len(), 0); // 2 non-empty vectors } @@ -1601,8 +1600,7 @@ pub mod tests { let input: Vec>> = vec![vec![]]; let cumulative = CumulativeOffsets::from_raw_2d(&input); - let src: Vec<_> = input.into_iter().flatten().collect(); - let len = src.len(); + let len = input.into_iter().flatten().count(); assert_eq!(cumulative.total_count, len); assert_eq!(cumulative.cumulative_offsets.len(), 0); // 2 non-empty vectors