summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2018-09-07 01:53:59 +0100
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-07 11:51:51 -0400
commit9dbcb303d6533a89b4edff14eacfdb0526444008 (patch)
tree643641157bf06bcc8d5b4bdfbdd524f23f04ab16
parent0ef3117cf085ee4e16e2800b6cb202412db019cc (diff)
downloadmailparse-9dbcb303d6533a89b4edff14eacfdb0526444008.tar.gz
mailparse-9dbcb303d6533a89b4edff14eacfdb0526444008.tar.xz
Tidy parse_param_content
-rw-r--r--src/lib.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f468513..6a70a69 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -813,17 +813,16 @@ fn parse_param_content(content: &str) -> ParamContent {
// There must be at least one token produced by split, even if it's empty.
let value = tokens.next().unwrap().trim();
let map = tokens
- .filter_map(|kv| if let Some(idx) = kv.find('=') {
- let key = kv[0..idx].trim().to_lowercase();
- let mut value = kv[idx + 1..].trim();
- if value.starts_with('"') && value.ends_with('"') {
- value = &value[1..value.len() - 1];
- }
- Some((key, value.to_string()))
- } else {
- None
- })
- .collect();
+ .filter_map(|kv| {
+ kv.find('=').map(|idx| {
+ let key = kv[0..idx].trim().to_lowercase();
+ let mut value = kv[idx + 1..].trim();
+ if value.starts_with('"') && value.ends_with('"') {
+ value = &value[1..value.len() - 1];
+ }
+ (key, value.to_string())
+ })
+ }).collect();
ParamContent {
value: value.into(),