summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2018-09-07 01:23:12 +0100
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-07 11:51:51 -0400
commit004ce278107014fbd465c85676e1bfe58b9e5dd1 (patch)
tree436d043a40a1751924a7f027c626db5fa8290c60
parentebd76203ab41efa8a2b0edc33d20b20e967848d2 (diff)
downloadmailparse-004ce278107014fbd465c85676e1bfe58b9e5dd1.tar.gz
mailparse-004ce278107014fbd465c85676e1bfe58b9e5dd1.tar.xz
Tidy MailHeader::get_key
-rw-r--r--src/lib.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a10b03a..8c47090 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -142,13 +142,10 @@ fn test_find_from_u8() {
impl<'a> MailHeader<'a> {
/// Get the name of the header. Note that header names are case-insensitive.
pub fn get_key(&self) -> Result<String, MailParseError> {
- Ok(
- try!(encoding::all::ISO_8859_1.decode(
- self.key,
- encoding::DecoderTrap::Strict,
- )).trim()
- .to_string(),
- )
+ encoding::all::ISO_8859_1
+ .decode(self.key, encoding::DecoderTrap::Strict)
+ .map(|s| s.trim().to_string())
+ .map_err(MailParseError::EncodingError)
}
fn decode_word(&self, encoded: &str) -> Option<String> {