fix(all): Formatting and style improvements

This commit is contained in:
Alexis Mousset
2019-04-14 18:21:44 +02:00
parent 10d362f509
commit 334ce235ff
5 changed files with 15 additions and 18 deletions

View File

@@ -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())

View File

@@ -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)?;

View File

@@ -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::<result::Result<Vec<_>, _>>()
.map_err(|_| ())?,
})

View File

@@ -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,

View File

@@ -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()