diff options
Diffstat (limited to 'src/mail/uidindex.rs')
-rw-r--r-- | src/mail/uidindex.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mail/uidindex.rs b/src/mail/uidindex.rs index 3a3e252..43d6507 100644 --- a/src/mail/uidindex.rs +++ b/src/mail/uidindex.rs @@ -214,9 +214,14 @@ impl FlagIndex { }); } fn remove(&mut self, uid: ImapUid, flags: &Vec<Flag>) -> () { - flags.iter().for_each(|flag| { - self.0.get_mut(flag).and_then(|set| set.remove(&uid)); - }); + for flag in flags.iter() { + if let Some(set) = self.0.get_mut(flag) { + set.remove(&uid); + if set.is_empty() { + self.0.remove(flag); + } + } + } } pub fn get(&self, f: &Flag) -> Option<&OrdSet<ImapUid>> { |