summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2018-09-07 02:19:40 +0100
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-07 11:51:51 -0400
commit59a9e608cc6b9ce7af946d9260056a86cbbcfe75 (patch)
tree3beb44bea6a5d10374434209e550ccf5644c5e6b /src/lib.rs
parent87eb8897eed8f9952c313a642f111fd1d255849e (diff)
Replace try_none! with ?
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e7a74a9..450c45a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,8 +9,6 @@ use std::collections::BTreeMap;
use encoding::Encoding;
-#[macro_use]
-mod macros;
mod dateparse;
pub use dateparse::dateparse;
@@ -147,15 +145,15 @@ impl<'a> MailHeader<'a> {
}
fn decode_word(&self, encoded: &str) -> Option<String> {
- let ix_delim1 = try_none!(encoded.find('?'));
- let ix_delim2 = try_none!(find_from(encoded, ix_delim1 + 1, "?"));
+ let ix_delim1 = encoded.find('?')?;
+ let ix_delim2 = find_from(encoded, ix_delim1 + 1, "?")?;
let charset = &encoded[0..ix_delim1];
let transfer_coding = &encoded[ix_delim1 + 1..ix_delim2];
let input = &encoded[ix_delim2 + 1..];
let decoded = match transfer_coding {
- "B" | "b" => try_none!(base64::decode(input.as_bytes()).ok()),
+ "B" | "b" => base64::decode(input.as_bytes()).ok()?,
"Q" | "q" => {
// The quoted_printable module does a trim_right on the input, so if
// that affects the output we should save and restore the trailing
@@ -169,11 +167,11 @@ impl<'a> MailHeader<'a> {
to_decode[trimmed.len()..].as_bytes(),
);
}
- try_none!(d.ok())
+ d.ok()?
}
_ => return None,
};
- let charset_conv = try_none!(encoding::label::encoding_from_whatwg_label(charset));
+ let charset_conv = encoding::label::encoding_from_whatwg_label(charset)?;
charset_conv
.decode(&decoded, encoding::DecoderTrap::Replace)
.ok()