From 004ce278107014fbd465c85676e1bfe58b9e5dd1 Mon Sep 17 00:00:00 2001 From: Thomas Hurst Date: Fri, 7 Sep 2018 01:23:12 +0100 Subject: Tidy MailHeader::get_key --- src/lib.rs | 11 ++++------- 1 file 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 { - 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 { -- cgit v1.2.3