Use .drain(..).flatten()

This commit is contained in:
Gwilym Kuiper 2022-03-18 21:12:46 +00:00
parent e9d3c6e5c4
commit ff709d9d57

View file

@ -164,16 +164,14 @@ impl<K, V> HashMap<K, V> {
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;