From 97d28609987546bcba65bed1db8d16ff156be2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 25 Sep 2024 22:15:15 +0200 Subject: [PATCH] Fix iterating on hashmap entries --- milli/src/update/new/extract/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/milli/src/update/new/extract/mod.rs b/milli/src/update/new/extract/mod.rs index 226e9aa6a..fe9f4a1bc 100644 --- a/milli/src/update/new/extract/mod.rs +++ b/milli/src/update/new/extract/mod.rs @@ -44,9 +44,9 @@ impl HashMapMerger { self.maps.extend(iter); } - pub fn iter<'h>(&'h self) -> Iter<'h> { + pub fn iter(&self) -> Iter<'_> { let mut entries: Vec<_> = - self.maps.iter().map(|m| m.iter()).flatten().map(|(k, v)| (k.as_slice(), v)).collect(); + self.maps.iter().flat_map(|m| m.iter()).map(|(k, v)| (k.as_slice(), v)).collect(); entries.par_sort_unstable_by_key(|(key, _)| *key); Iter { sorted_entries: entries.into_iter(), @@ -74,7 +74,9 @@ impl<'h> Iterator for Iter<'h> { } else { let previous_key = self.current_key.replace(k); let previous_deladd = mem::replace(&mut self.current_deladd, other.clone()); - return previous_key.map(|ck| (ck, previous_deladd)); + if let Some(previous_key) = previous_key { + return Some((previous_key, previous_deladd)); + } } } None => {