From d3d2509273dd2178cf272a63e20f1e8d38beb406 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 18 Nov 2024 19:11:18 +0000 Subject: [PATCH] refactor: remove indexing/slicing from `parse_message_ids` --- src/mimeparser.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 5a435a14c..e2c7583aa 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1915,18 +1915,17 @@ pub(crate) struct DeliveryReport { pub failure: bool, } -#[allow(clippy::indexing_slicing)] pub(crate) fn parse_message_ids(ids: &str) -> Vec { // take care with mailparse::msgidparse() that is pretty untolerant eg. wrt missing `<` or `>` let mut msgids = Vec::new(); for id in ids.split_whitespace() { let mut id = id.to_string(); - if id.starts_with('<') { - id = id[1..].to_string(); - } - if id.ends_with('>') { - id = id[..id.len() - 1].to_string(); - } + if let Some(id_without_prefix) = id.strip_prefix('<') { + id = id_without_prefix.to_string(); + }; + if let Some(id_without_suffix) = id.strip_suffix('>') { + id = id_without_suffix.to_string(); + }; if !id.is_empty() { msgids.push(id); }