From 0327000f8dcd2f6d3c019a707daa9a3ba5863825 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 28 Mar 2020 03:18:12 +0300 Subject: [PATCH] squash_attachment_parts: use slice patterns --- src/mimeparser.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 513697ff9..e498e1453 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -203,10 +203,12 @@ impl MimeMessage { /// Delta Chat sends attachments, such as images, in two-part messages, with the first message /// containing an explanation. If such a message is detected, first part can be safely dropped. fn squash_attachment_parts(&mut self) { - if self.has_chat_version() && self.parts.len() == 2 { + if !self.has_chat_version() { + return; + } + + if let [textpart, filepart] = &self.parts[..] { let need_drop = { - let textpart = &self.parts[0]; - let filepart = &self.parts[1]; textpart.typ == Viewtype::Text && (filepart.typ == Viewtype::Image || filepart.typ == Viewtype::Gif