summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2018-09-07 02:33:40 +0100
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-07 11:51:51 -0400
commit30baefc366c26a31318fd9053b768fa50616c344 (patch)
tree8e4bce9e9e0dcf83cd3cd65bcdb04845a3af78ab
parent59a9e608cc6b9ce7af946d9260056a86cbbcfe75 (diff)
downloadmailparse-30baefc366c26a31318fd9053b768fa50616c344.tar.gz
mailparse-30baefc366c26a31318fd9053b768fa50616c344.tar.xz
Prefer map_err(|e| e.into()) over explicit error
-rw-r--r--src/lib.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 450c45a..96c01ca 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -141,7 +141,7 @@ impl<'a> MailHeader<'a> {
encoding::all::ISO_8859_1
.decode(self.key, encoding::DecoderTrap::Strict)
.map(|s| s.trim().to_string())
- .map_err(MailParseError::EncodingError)
+ .map_err(|e| e.into())
}
fn decode_word(&self, encoded: &str) -> Option<String> {
@@ -657,8 +657,8 @@ impl<'a> ParsedMail<'a> {
let decoded = self.get_body_raw()?;
let charset_conv = encoding::label::encoding_from_whatwg_label(&self.ctype.charset)
.unwrap_or(encoding::all::ASCII);
- let str_body = charset_conv.decode(&decoded, encoding::DecoderTrap::Replace)?;
- Ok(str_body)
+ charset_conv.decode(&decoded, encoding::DecoderTrap::Replace)
+ .map_err(|e| e.into())
}
/// Get the body of the message as a Rust Vec<u8>. This function tries to