From 32e022d821416f08531bb4a4fee2d102ddd04c40 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Sat, 28 May 2016 01:48:46 -0400 Subject: rustfmt --- src/lib.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 573b450..c7bd77c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,10 +22,12 @@ pub fn parse_header(raw_data: &str) -> Result<(MailHeader, usize), MailParseErro let mut it = raw_data.chars(); let mut ix = 0; let mut c = match it.next() { - None => return Err(MailParseError { + None => { + return Err(MailParseError { description: "Empty string provided".to_string(), position: 0, - }), + }) + } Some(v) => v, }; @@ -39,13 +41,15 @@ pub fn parse_header(raw_data: &str) -> Result<(MailHeader, usize), MailParseErro HeaderParseState::Initial => { if c == ' ' { return Err(MailParseError { - description: "Header cannot start with a space; it is likely an overhanging line from a previous header".to_string(), + description: "Header cannot start with a space; it is likely an \ + overhanging line from a previous header" + .to_string(), position: ix, }); }; state = HeaderParseState::Key; continue; - }, + } HeaderParseState::Key => { if c == ':' { ix_key_end = Some(ix); @@ -88,15 +92,20 @@ pub fn parse_header(raw_data: &str) -> Result<(MailHeader, usize), MailParseErro }; } match ix_key_end { - Some(v) => Ok((MailHeader { - key: &raw_data[0..v], - value: &raw_data[ix_value_start..ix_value_end], - }, ix)), + Some(v) => { + Ok((MailHeader { + key: &raw_data[0..v], + value: &raw_data[ix_value_start..ix_value_end], + }, + ix)) + } - None => Err(MailParseError { - description: "Unable to determine end of the header key component".to_string(), - position: ix, - }), + None => { + Err(MailParseError { + description: "Unable to determine end of the header key component".to_string(), + position: ix, + }) + } } } -- cgit v1.2.3