From 24aa3c781b9ddd6da40bf5dc6903e9b6208e4567 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 28 Mar 2020 02:23:54 +0300 Subject: [PATCH] Remove indexing in Aheader::from_str --- src/aheader.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/aheader.rs b/src/aheader.rs index 628de89f7..6dee60eeb 100644 --- a/src/aheader.rs +++ b/src/aheader.rs @@ -127,14 +127,10 @@ impl str::FromStr for Aheader { .split(';') .filter_map(|a| { let attribute: Vec<&str> = a.trim().splitn(2, '=').collect(); - if attribute.len() < 2 { - return None; + match &attribute[..] { + [key, value] => Some((key.trim().to_string(), value.trim().to_string())), + _ => None, } - - Some(( - attribute[0].trim().to_string(), - attribute[1].trim().to_string(), - )) }) .collect();