From 4332d09f0d8d27c3fca6d2cfee7e40f9ee323567 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Thu, 2 Nov 2017 22:56:22 -0400 Subject: [PATCH] cargo fmt --- src/client.rs | 34 +++++++++++++++++++++------------- src/error.rs | 9 ++++++--- src/parse.rs | 4 +--- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/client.rs b/src/client.rs index 676b08a..9d296a9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -8,7 +8,7 @@ use super::mailbox::Mailbox; use super::authenticator::Authenticator; use super::parse::{parse_authenticate_response, parse_capability, parse_response, parse_response_ok, parse_select_or_examine}; -use super::error::{Error, Result, ParseError, ValidateError}; +use super::error::{Error, ParseError, Result, ValidateError}; static TAG_PREFIX: &'static str = "a"; const INITIAL_TAG: u32 = 0; @@ -304,13 +304,17 @@ impl Client { /// Selects a mailbox pub fn select(&mut self, mailbox_name: &str) -> Result { - let lines = try!(self.run_command_and_read_response(&format!("SELECT {}", validate_str(mailbox_name)?))); + let lines = try!( + self.run_command_and_read_response(&format!("SELECT {}", validate_str(mailbox_name)?)) + ); parse_select_or_examine(lines) } /// Examine is identical to Select, but the selected mailbox is identified as read-only pub fn examine(&mut self, mailbox_name: &str) -> Result { - let lines = try!(self.run_command_and_read_response(&format!("EXAMINE {}", validate_str(mailbox_name)?))); + let lines = try!( + self.run_command_and_read_response(&format!("EXAMINE {}", validate_str(mailbox_name)?)) + ); parse_select_or_examine(lines) } @@ -487,7 +491,8 @@ impl Client { while !found_tag_line { let raw_data = try!(self.readline()); - let line = String::from_utf8(raw_data).map_err(|err| Error::Parse(ParseError::DataNotUtf8(err)))?; + let line = String::from_utf8(raw_data) + .map_err(|err| Error::Parse(ParseError::DataNotUtf8(err)))?; lines.push(line.clone()); if (&*line).starts_with(&*start_str) { found_tag_line = true; @@ -753,7 +758,8 @@ mod tests { #[test] fn select() { let response = b"* FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\r\n\ - * OK [PERMANENTFLAGS (\\* \\Answered \\Flagged \\Deleted \\Draft \\Seen)] Read-only mailbox.\r\n\ + * OK [PERMANENTFLAGS (\\* \\Answered \\Flagged \\Deleted \\Draft \\Seen)] \ + Read-only mailbox.\r\n\ * 1 EXISTS\r\n\ * 1 RECENT\r\n\ * OK [UNSEEN 1] First unseen.\r\n\ @@ -857,12 +863,12 @@ mod tests { #[test] fn store() { - generic_store(" ", |mut c, set, query| c.store(set, query)); + generic_store(" ", |c, set, query| c.store(set, query)); } #[test] fn uid_store() { - generic_store(" UID ", |mut c, set, query| c.uid_store(set, query)); + generic_store(" UID ", |c, set, query| c.uid_store(set, query)); } fn generic_store(prefix: &str, op: F) @@ -879,12 +885,12 @@ mod tests { #[test] fn copy() { - generic_copy(" ", |mut c, set, query| c.copy(set, query)) + generic_copy(" ", |c, set, query| c.copy(set, query)) } #[test] fn uid_copy() { - generic_copy(" UID ", |mut c, set, query| c.uid_copy(set, query)) + generic_copy(" UID ", |c, set, query| c.uid_copy(set, query)) } fn generic_copy(prefix: &str, op: F) @@ -903,12 +909,12 @@ mod tests { #[test] fn fetch() { - generic_fetch(" ", |mut c, seq, query| c.fetch(seq, query)) + generic_fetch(" ", |c, seq, query| c.fetch(seq, query)) } #[test] fn uid_fetch() { - generic_fetch(" UID ", |mut c, seq, query| c.uid_fetch(seq, query)) + generic_fetch(" UID ", |c, seq, query| c.uid_fetch(seq, query)) } fn generic_fetch(prefix: &str, op: F) @@ -944,8 +950,10 @@ mod tests { #[test] fn validate_random() { - assert_eq!("\"~iCQ_k;>[&\\\"sVCvUW`e<[&\"sVCvUW`e<[&\\\"sVCvUW`e<[&\"sVCvUW`e< fmt::Display::fmt(e, f), Error::TlsHandshake(ref e) => fmt::Display::fmt(e, f), Error::Validate(ref e) => fmt::Display::fmt(e, f), - Error::BadResponse(ref data) => { - write!(f, "{}: {}", &String::from(self.description()), &data.join("\n")) - } + Error::BadResponse(ref data) => write!( + f, + "{}: {}", + &String::from(self.description()), + &data.join("\n") + ), ref e => f.write_str(e.description()), } } diff --git a/src/parse.rs b/src/parse.rs index 2790bb8..13ceca7 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -125,9 +125,7 @@ mod tests { String::from("LOGINDISABLED"), ]; let lines = vec![ - String::from( - "* CAPABILITY IMAP4rev1 STARTTLS AUTH=GSSAPI LOGINDISABLED\r\n", - ), + String::from("* CAPABILITY IMAP4rev1 STARTTLS AUTH=GSSAPI LOGINDISABLED\r\n"), String::from("a1 OK CAPABILITY completed\r\n"), ]; let capabilities = parse_capability(lines).unwrap();