From ff709d9d57155cbf55faa42c131e6f4e3226cfb2 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Fri, 18 Mar 2022 21:12:46 +0000 Subject: [PATCH] Use .drain(..).flatten() --- agb/src/hash_map.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/agb/src/hash_map.rs b/agb/src/hash_map.rs index 58f9daa0..4703409b 100644 --- a/agb/src/hash_map.rs +++ b/agb/src/hash_map.rs @@ -164,16 +164,14 @@ impl HashMap { let mut new_max_distance_to_initial_bucket = 0; let number_of_elements = self.number_of_elements; - for node in self.nodes.0.drain(..) { - if let Some(node) = node { - new_max_distance_to_initial_bucket = new_node_storage.insert_new( - node.key, - node.value, - node.hash, - number_of_elements, - new_max_distance_to_initial_bucket, - ); - } + for node in self.nodes.0.drain(..).flatten() { + new_max_distance_to_initial_bucket = new_node_storage.insert_new( + node.key, + node.value, + node.hash, + number_of_elements, + new_max_distance_to_initial_bucket, + ); } self.nodes = new_node_storage;