From bc60857ce4890a0e0439318371bd2724278dd5c0 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Sat, 30 Nov 2019 12:18:03 +0100 Subject: [PATCH] Fix clippy warnings --- lettre/src/lib.rs | 4 ++-- lettre/src/smtp/commands.rs | 4 +++- lettre_email/src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lettre/src/lib.rs b/lettre/src/lib.rs index da52bdf..9f6cfd7 100644 --- a/lettre/src/lib.rs +++ b/lettre/src/lib.rs @@ -50,7 +50,7 @@ pub struct EmailAddress(String); impl EmailAddress { pub fn new(address: String) -> EmailResult { if !EmailAddress::is_valid(&address) { - Err(Error::InvalidEmailAddress)?; + return Err(Error::InvalidEmailAddress); } Ok(EmailAddress(address)) } @@ -108,7 +108,7 @@ impl Envelope { /// Creates a new envelope, which may fail if `to` is empty. pub fn new(from: Option, to: Vec) -> EmailResult { if to.is_empty() { - Err(Error::MissingTo)?; + return Err(Error::MissingTo); } Ok(Envelope { forward_path: to, diff --git a/lettre/src/smtp/commands.rs b/lettre/src/smtp/commands.rs index 4ffaf6b..8176826 100644 --- a/lettre/src/smtp/commands.rs +++ b/lettre/src/smtp/commands.rs @@ -20,6 +20,7 @@ pub struct EhloCommand { impl Display for EhloCommand { fn fmt(&self, f: &mut Formatter) -> fmt::Result { + #[allow(clippy::write_with_newline)] write!(f, "EHLO {}\r\n", self.client_id) } } @@ -165,7 +166,7 @@ pub struct VrfyCommand { impl Display for VrfyCommand { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - #[cfg_attr(feature = "cargo-clippy", allow(clippy::write_with_newline))] + #[allow(clippy::write_with_newline)] write!(f, "VRFY {}\r\n", self.argument) } } @@ -186,6 +187,7 @@ pub struct ExpnCommand { impl Display for ExpnCommand { fn fmt(&self, f: &mut Formatter) -> fmt::Result { + #[allow(clippy::write_with_newline)] write!(f, "EXPN {}\r\n", self.argument) } } diff --git a/lettre_email/src/lib.rs b/lettre_email/src/lib.rs index 928b3dd..3c5c4ab 100644 --- a/lettre_email/src/lib.rs +++ b/lettre_email/src/lib.rs @@ -439,7 +439,7 @@ impl EmailBuilder { .message .header(Header::new_with_value("From".into(), from).unwrap()); } else { - Err(Error::Envelope(LettreError::MissingFrom))?; + return Err(Error::Envelope(LettreError::MissingFrom)); } if !self.cc.is_empty() { self.message = self