summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKartikaya Gupta <kats@seldon.staktrace.com>2016-05-28 01:48:46 -0400
committerKartikaya Gupta <kats@seldon.staktrace.com>2016-05-28 01:48:46 -0400
commit32e022d821416f08531bb4a4fee2d102ddd04c40 (patch)
tree85c7106e3cf3bc6dcc1214f6362b85aa2619716f
parent4871e27193c99a0f3940d2dbc16bef8d03be2222 (diff)
rustfmt
-rw-r--r--src/lib.rs33
1 files changed, 21 insertions, 12 deletions
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,
+ })
+ }
}
}