diff options
author | Kartikaya Gupta <kats@seldon.staktrace.com> | 2016-05-28 02:19:45 -0400 |
---|---|---|
committer | Kartikaya Gupta <kats@seldon.staktrace.com> | 2016-05-28 02:22:49 -0400 |
commit | f9c66fe6ebee1e42f2bfe22da136c70e230db088 (patch) | |
tree | 0b965525d028a3b436c64e6e9c504668acb2d7b6 | |
parent | d2b8a3bcc63a93a7ddf7ece26e3d25876a37675a (diff) |
Make code a bit more compact
-rw-r--r-- | src/lib.rs | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -113,10 +113,7 @@ pub fn parse_headers(raw_data: &str) -> Result<Vec<MailHeader>, MailParseError> let mut headers: Vec<MailHeader> = Vec::new(); let mut ix = 0; loop { - let (header, ix_end) = match parse_header(&raw_data[ix..]) { - Ok(v) => v, - Err(e) => return Err(MailParseError {description: e.description, position: e.position + ix}), - }; + let (header, ix_end) = try!(parse_header(&raw_data[ix..]).map_err(|e| MailParseError { description: e.description, position: e.position + ix })); headers.push(header); ix = ix + ix_end; if ix >= raw_data.len() || raw_data.chars().nth(ix) == Some('\n') { |