diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-05-30 14:40:47 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-05-30 14:43:44 +0300 |
commit | 815ff98acc73201bfbd079414104169162a0fa0d (patch) | |
tree | f9edad2491a316f77e806a5d1795acdf11e42d49 /melib/src/email/parser.rs | |
parent | 2c45c390480ab9e9326b3cf514460cf9e2807abb (diff) |
imap: add smarter untagged reply detection
Diffstat (limited to 'melib/src/email/parser.rs')
-rw-r--r-- | melib/src/email/parser.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/melib/src/email/parser.rs b/melib/src/email/parser.rs index 827550fe..b0380cfb 100644 --- a/melib/src/email/parser.rs +++ b/melib/src/email/parser.rs @@ -105,6 +105,22 @@ impl BytesExt for [u8] { } } +pub trait BytesIterExt { + fn join(&mut self, sep: u8) -> Vec<u8>; +} + +impl<'a, P: for<'r> FnMut(&'r u8) -> bool> BytesIterExt for std::slice::Split<'a, u8, P> { + fn join(&mut self, sep: u8) -> Vec<u8> { + self.fold(vec![], |mut acc, el| { + if !acc.is_empty() { + acc.push(sep); + } + acc.extend(el.iter()); + acc + }) + } +} + fn quoted_printable_byte(input: &[u8]) -> IResult<&[u8], u8> { if input.len() < 3 { IResult::Incomplete(Needed::Size(1)) |