diff options
author | Thomas Hurst <tom@hur.st> | 2018-09-07 01:23:12 +0100 |
---|---|---|
committer | Kartikaya Gupta (kats) <staktrace@users.noreply.github.com> | 2018-09-07 11:51:51 -0400 |
commit | 004ce278107014fbd465c85676e1bfe58b9e5dd1 (patch) | |
tree | 436d043a40a1751924a7f027c626db5fa8290c60 | |
parent | ebd76203ab41efa8a2b0edc33d20b20e967848d2 (diff) |
Tidy MailHeader::get_key
-rw-r--r-- | src/lib.rs | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -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> { |