style(all): Run clippy without errors

This commit is contained in:
Alexis Mousset
2017-05-21 13:09:31 +02:00
parent 3b4434467a
commit 73c5630634
7 changed files with 18 additions and 42 deletions

View File

@@ -1,30 +0,0 @@
extern crate lettre;
use lettre::email::EmailBuilder;
use lettre::transport::EmailTransport;
use lettre::transport::smtp::SmtpTransportBuilder;
fn main() {
let email = EmailBuilder::new()
// Addresses can be specified by the tuple (email, alias)
.to(("user@example.org", "Firstname Lastname"))
// ... or by an address only
.from("user@example.com")
.subject("Hi, Hello world")
.text("Hello world.")
.build()
.unwrap();
// Open a local connection on port 25
let mut mailer = SmtpTransportBuilder::localhost().unwrap().build();
// Send the email
let result = mailer.send(email);
if result.is_ok() {
println!("Email sent");
} else {
println!("Could not send email: {:?}", result);
}
assert!(result.is_ok());
}

View File

@@ -133,6 +133,7 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
}
/// Checks if the server is connected using the NOOP SMTP command
#[cfg_attr(feature = "cargo-clippy", allow(wrong_self_convention))]
pub fn is_connected(&mut self) -> bool {
self.noop().is_ok()
}

View File

@@ -27,7 +27,7 @@ impl Connector for NetworkStream {
match Ssl::new(context) {
Ok(ssl) => {
ssl.connect(tcp_stream)
.map(|s| NetworkStream::Ssl(s))
.map(NetworkStream::Ssl)
.map_err(|e| io::Error::new(ErrorKind::Other, e))
}
Err(e) => Err(io::Error::new(ErrorKind::Other, e)),

View File

@@ -53,9 +53,13 @@ pub struct ServerInfo {
impl Display for ServerInfo {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{} with {}", self.name, match self.features.is_empty() {
true => "no supported features".to_string(),
false => format!("{:?}", self.features),
write!(f,
"{} with {}",
self.name,
if self.features.is_empty() {
"no supported features".to_string()
} else {
format!("{:?}", self.features)
})
}
}

View File

@@ -286,6 +286,7 @@ impl SmtpTransport {
impl EmailTransport<SmtpResult> for SmtpTransport {
/// Sends an email
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms, cyclomatic_complexity))]
fn send<T: SendableEmail>(&mut self, email: T) -> SmtpResult {
// Extract email information
@@ -299,8 +300,8 @@ impl EmailTransport<SmtpResult> for SmtpTransport {
if self.state.connection_reuse_count == 0 {
try!(self.client
.connect(&self.client_info.server_addr,
match &self.client_info.security_level {
&SecurityLevel::EncryptedWrapper => {
match self.client_info.security_level {
SecurityLevel::EncryptedWrapper => {
Some(&self.client_info.ssl_context)
}
_ => None,
@@ -396,7 +397,7 @@ impl EmailTransport<SmtpResult> for SmtpTransport {
// Recipient
for to_address in &email.to() {
try_smtp!(self.client.rcpt(&to_address), self);
try_smtp!(self.client.rcpt(to_address), self);
// Log the rcpt command
info!("{}: to=<{}>", message_id, to_address);
}

View File

@@ -1,9 +1,9 @@
extern crate lettre;
extern crate lettre_email;
use lettre_email::email::EmailBuilder;
use lettre::EmailTransport;
use lettre::smtp::SmtpTransportBuilder;
use lettre_email::email::EmailBuilder;
fn main() {
let email = EmailBuilder::new()

View File

@@ -1,13 +1,13 @@
//! Simple email representation
use error::Error;
use email_format::{Address, Header, Mailbox, MimeMessage, MimeMultipartType};
use error::Error;
use lettre::SendableEmail;
use mime::Mime;
use std::fmt;
use std::fmt::{Display, Formatter};
use time::{Tm, now};
use uuid::Uuid;
use lettre::SendableEmail;
/// Converts an address or an address with an alias to a `Header`
pub trait IntoHeader {
@@ -776,9 +776,9 @@ pub trait ExtractableEmail {
#[cfg(test)]
mod test {
use lettre::SendableEmail;
use super::{Email, EmailBuilder, Envelope, IntoEmail, SimpleEmail};
use email_format::{Header, MimeMessage};
use lettre::SendableEmail;
use time::now;
use uuid::Uuid;