diff --git a/lettre/src/sendmail/mod.rs b/lettre/src/sendmail/mod.rs index c594a73..14c107e 100644 --- a/lettre/src/sendmail/mod.rs +++ b/lettre/src/sendmail/mod.rs @@ -5,6 +5,7 @@ use crate::sendmail::error::SendmailResult; use crate::SendableEmail; use crate::Transport; use log::info; +use std::convert::AsRef; use std::io::prelude::*; use std::io::Read; use std::process::{Command, Stdio}; @@ -47,13 +48,7 @@ impl<'a> Transport<'a> for SendmailTransport { let mut process = Command::new(&self.command) .arg("-i") .arg("-f") - .arg( - email - .envelope() - .from() - .map(|x| x.as_ref()) - .unwrap_or("\"\""), - ) + .arg(email.envelope().from().map(AsRef::as_ref).unwrap_or("\"\"")) .args(email.envelope.to()) .stdin(Stdio::piped()) .stdout(Stdio::piped()) diff --git a/lettre/src/smtp/commands.rs b/lettre/src/smtp/commands.rs index 8cda6af..0e04921 100644 --- a/lettre/src/smtp/commands.rs +++ b/lettre/src/smtp/commands.rs @@ -1,4 +1,3 @@ - //! SMTP commands use crate::smtp::authentication::{Credentials, Mechanism}; @@ -9,6 +8,7 @@ use crate::smtp::response::Response; use crate::EmailAddress; use base64; use log::debug; +use std::convert::AsRef; use std::fmt::{self, Display, Formatter}; /// EHLO command @@ -64,7 +64,7 @@ impl Display for MailCommand { write!( f, "MAIL FROM:<{}>", - self.sender.as_ref().map(|x| x.as_ref()).unwrap_or("") + self.sender.as_ref().map(AsRef::as_ref).unwrap_or("") )?; for parameter in &self.parameters { write!(f, " {}", parameter)?; diff --git a/lettre/src/smtp/response.rs b/lettre/src/smtp/response.rs index 9527067..69aff35 100644 --- a/lettre/src/smtp/response.rs +++ b/lettre/src/smtp/response.rs @@ -6,6 +6,7 @@ use nom::{crlf, ErrorKind as NomErrorKind}; use std::fmt::{Display, Formatter, Result}; use std::result; use std::str::{from_utf8, FromStr}; +use std::string::ToString; /// First digit indicates severity #[derive(PartialEq, Eq, Copy, Clone, Debug)] @@ -269,7 +270,7 @@ named!( code: last_code, message: lines .into_iter() - .map(|line| from_utf8(line).map(|s| s.to_string())) + .map(|line| from_utf8(line).map(ToString::to_string)) .collect::, _>>() .map_err(|_| ())?, }) diff --git a/lettre_email/src/lib.rs b/lettre_email/src/lib.rs index 9d928da..05d25a9 100644 --- a/lettre_email/src/lib.rs +++ b/lettre_email/src/lib.rs @@ -19,6 +19,7 @@ use crate::error::Error; pub use email::{Address, Header, Mailbox, MimeMessage, MimeMultipartType}; use lettre::{error::Error as LettreError, EmailAddress, Envelope, SendableEmail}; use mime::Mime; +use std::ffi::OsStr; use std::fs; use std::path::Path; use std::str::FromStr; @@ -250,7 +251,7 @@ impl EmailBuilder { fs::read(path)?.as_slice(), filename.unwrap_or( path.file_name() - .and_then(|x| x.to_str()) + .and_then(OsStr::to_str) .ok_or(Error::CannotParseFilename)?, ), content_type, diff --git a/lettre_email/tests/skeptic.rs b/lettre_email/tests/skeptic.rs index 33756b4..43ed564 100644 --- a/lettre_email/tests/skeptic.rs +++ b/lettre_email/tests/skeptic.rs @@ -8,13 +8,13 @@ use std::process::Command; fn book_test() { let mut book_path = env::current_dir().unwrap(); let readme = Path::new(file!()) - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .join("../README.md"); + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .join("../README.md"); book_path.push( Path::new(file!()) .parent()