From 7f545301e1c1964f7698d59dd69824eac32ca06d Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Mon, 28 May 2018 23:46:05 +0200 Subject: [PATCH] style(all): Run rustfmt and clippy --- lettre/benches/transport_smtp.rs | 2 +- lettre/src/file/mod.rs | 2 +- lettre/src/lib.rs | 22 +++++++++++----------- lettre/src/sendmail/mod.rs | 2 +- lettre/src/smtp/authentication.rs | 12 +++++++++--- lettre/src/smtp/client/mod.rs | 4 ++-- lettre/src/smtp/commands.rs | 2 +- lettre/src/smtp/mod.rs | 10 +++++----- lettre/src/smtp/response.rs | 2 +- lettre/src/stub/mod.rs | 2 +- lettre/tests/skeptic.rs | 2 +- lettre/tests/transport_file.rs | 2 +- lettre/tests/transport_sendmail.rs | 2 +- lettre/tests/transport_stub.rs | 2 +- lettre_email/src/lib.rs | 2 +- lettre_email/tests/skeptic.rs | 2 +- 16 files changed, 39 insertions(+), 33 deletions(-) diff --git a/lettre/benches/transport_smtp.rs b/lettre/benches/transport_smtp.rs index 0b2d7c1..406adfd 100644 --- a/lettre/benches/transport_smtp.rs +++ b/lettre/benches/transport_smtp.rs @@ -3,9 +3,9 @@ extern crate lettre; extern crate test; +use lettre::smtp::ConnectionReuseParameters; use lettre::{ClientSecurity, Envelope, SmtpTransport}; use lettre::{EmailAddress, SendableEmail, Transport}; -use lettre::smtp::ConnectionReuseParameters; #[bench] fn bench_simple_send(b: &mut test::Bencher) { diff --git a/lettre/src/file/mod.rs b/lettre/src/file/mod.rs index f5e1962..cbe7688 100644 --- a/lettre/src/file/mod.rs +++ b/lettre/src/file/mod.rs @@ -3,9 +3,9 @@ //! It can be useful for testing purposes, or if you want to keep track of sent messages. //! -use Transport; use Envelope; use SendableEmail; +use Transport; use file::error::FileResult; use serde_json; use std::fs::File; diff --git a/lettre/src/lib.rs b/lettre/src/lib.rs index 07a22cb..1d84210 100644 --- a/lettre/src/lib.rs +++ b/lettre/src/lib.rs @@ -27,27 +27,27 @@ extern crate serde_derive; #[cfg(feature = "file-transport")] extern crate serde_json; -#[cfg(feature = "smtp-transport")] -pub mod smtp; -#[cfg(feature = "sendmail-transport")] -pub mod sendmail; -pub mod stub; #[cfg(feature = "file-transport")] pub mod file; +#[cfg(feature = "sendmail-transport")] +pub mod sendmail; +#[cfg(feature = "smtp-transport")] +pub mod smtp; +pub mod stub; #[cfg(feature = "file-transport")] pub use file::FileTransport; #[cfg(feature = "sendmail-transport")] pub use sendmail::SendmailTransport; #[cfg(feature = "smtp-transport")] -pub use smtp::{ClientSecurity, SmtpClient, SmtpTransport}; -#[cfg(feature = "smtp-transport")] pub use smtp::client::net::ClientTlsParameters; -use std::fmt::{self, Display, Formatter}; -use std::io::Read; -use std::io::Cursor; -use std::io; +#[cfg(feature = "smtp-transport")] +pub use smtp::{ClientSecurity, SmtpClient, SmtpTransport}; use std::error::Error as StdError; +use std::fmt::{self, Display, Formatter}; +use std::io; +use std::io::Cursor; +use std::io::Read; use std::str::FromStr; /// Error type for email content diff --git a/lettre/src/sendmail/mod.rs b/lettre/src/sendmail/mod.rs index 865382c..c1a6a38 100644 --- a/lettre/src/sendmail/mod.rs +++ b/lettre/src/sendmail/mod.rs @@ -1,8 +1,8 @@ //! The sendmail transport sends the email using the local sendmail command. //! -use Transport; use SendableEmail; +use Transport; use sendmail::error::SendmailResult; use std::io::Read; use std::io::prelude::*; diff --git a/lettre/src/smtp/authentication.rs b/lettre/src/smtp/authentication.rs index be15826..9a6e685 100644 --- a/lettre/src/smtp/authentication.rs +++ b/lettre/src/smtp/authentication.rs @@ -40,7 +40,10 @@ pub struct Credentials { impl Credentials { /// Create a `Credentials` struct from username and password pub fn new(username: String, password: String) -> Credentials { - Credentials { authentication_identity: username, secret: password } + Credentials { + authentication_identity: username, + secret: password, + } } } @@ -113,7 +116,7 @@ impl Mechanism { } Err(Error::Client("Unrecognized challenge")) - }, + } Mechanism::Xoauth2 => match challenge { Some(_) => Err(Error::Client("This mechanism does not expect a challenge")), None => Ok(format!( @@ -163,7 +166,10 @@ mod test { fn test_xoauth2() { let mechanism = Mechanism::Xoauth2; - let credentials = Credentials::new("username".to_string(), "vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==".to_string()); + let credentials = Credentials::new( + "username".to_string(), + "vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==".to_string(), + ); assert_eq!( mechanism.response(&credentials, None).unwrap(), diff --git a/lettre/src/smtp/client/mod.rs b/lettre/src/smtp/client/mod.rs index 9328e5e..c2c1843 100644 --- a/lettre/src/smtp/client/mod.rs +++ b/lettre/src/smtp/client/mod.rs @@ -13,8 +13,8 @@ use std::net::ToSocketAddrs; use std::string::String; use std::time::Duration; -pub mod net; pub mod mock; +pub mod net; /// The codec used for transparency #[derive(Default, Clone, Copy, Debug)] @@ -218,7 +218,7 @@ impl InnerClient { self.write(out_buf.as_slice())?; } - self.write("\r\n.\r\n".as_bytes())?; + self.write(b"\r\n.\r\n")?; self.read_response() } diff --git a/lettre/src/smtp/commands.rs b/lettre/src/smtp/commands.rs index 133c263..7360312 100644 --- a/lettre/src/smtp/commands.rs +++ b/lettre/src/smtp/commands.rs @@ -4,8 +4,8 @@ use EmailAddress; use base64; use smtp::authentication::{Credentials, Mechanism}; use smtp::error::Error; -use smtp::extension::{MailParameter, RcptParameter}; use smtp::extension::ClientId; +use smtp::extension::{MailParameter, RcptParameter}; use smtp::response::Response; use std::fmt::{self, Display, Formatter}; diff --git a/lettre/src/smtp/mod.rs b/lettre/src/smtp/mod.rs index 4f0d780..398eb7f 100644 --- a/lettre/src/smtp/mod.rs +++ b/lettre/src/smtp/mod.rs @@ -13,7 +13,6 @@ //! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531)) //! -use {SendableEmail, Transport}; use native_tls::TlsConnector; use smtp::authentication::{Credentials, Mechanism, DEFAULT_ENCRYPTED_MECHANISMS, DEFAULT_UNENCRYPTED_MECHANISMS}; @@ -25,13 +24,14 @@ use smtp::error::{Error, SmtpResult}; use smtp::extension::{ClientId, Extension, MailBodyParameter, MailParameter, ServerInfo}; use std::net::{SocketAddr, ToSocketAddrs}; use std::time::Duration; +use {SendableEmail, Transport}; -pub mod extension; -pub mod commands; pub mod authentication; -pub mod response; pub mod client; +pub mod commands; pub mod error; +pub mod extension; +pub mod response; pub mod util; // Registered port numbers: @@ -404,7 +404,7 @@ impl<'a> Transport<'a> for SmtpTransport { for to_address in email.envelope().to() { try_smtp!( self.client - .command(RcptCommand::new(to_address.clone(), vec![]),), + .command(RcptCommand::new(to_address.clone(), vec![])), self ); // Log the rcpt command diff --git a/lettre/src/smtp/response.rs b/lettre/src/smtp/response.rs index c4299f1..3fb2110 100644 --- a/lettre/src/smtp/response.rs +++ b/lettre/src/smtp/response.rs @@ -1,8 +1,8 @@ //! SMTP response, containing a mandatory return code and an optional text //! message -use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult}; use nom::simple_errors::Err as NomError; +use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult}; use std::fmt::{Display, Formatter, Result}; use std::result; use std::str::{FromStr, from_utf8}; diff --git a/lettre/src/stub/mod.rs b/lettre/src/stub/mod.rs index 1030e0c..c221ab6 100644 --- a/lettre/src/stub/mod.rs +++ b/lettre/src/stub/mod.rs @@ -2,8 +2,8 @@ //! testing purposes. //! -use Transport; use SendableEmail; +use Transport; /// This transport logs the message envelope and returns the given response #[derive(Debug, Clone, Copy)] diff --git a/lettre/tests/skeptic.rs b/lettre/tests/skeptic.rs index af48816..0b61213 100644 --- a/lettre/tests/skeptic.rs +++ b/lettre/tests/skeptic.rs @@ -1,8 +1,8 @@ extern crate glob; use self::glob::glob; -use std::env::consts::EXE_EXTENSION; use std::env; +use std::env::consts::EXE_EXTENSION; use std::path::Path; use std::process::Command; diff --git a/lettre/tests/transport_file.rs b/lettre/tests/transport_file.rs index 572fd79..e231e43 100644 --- a/lettre/tests/transport_file.rs +++ b/lettre/tests/transport_file.rs @@ -4,8 +4,8 @@ extern crate lettre; #[cfg(feature = "file-transport")] mod test { - use lettre::{EmailAddress, Envelope, SendableEmail, Transport}; use lettre::file::FileTransport; + use lettre::{EmailAddress, Envelope, SendableEmail, Transport}; use std::env::temp_dir; use std::fs::File; use std::fs::remove_file; diff --git a/lettre/tests/transport_sendmail.rs b/lettre/tests/transport_sendmail.rs index 06a83bd..41d86f8 100644 --- a/lettre/tests/transport_sendmail.rs +++ b/lettre/tests/transport_sendmail.rs @@ -3,8 +3,8 @@ extern crate lettre; #[cfg(test)] #[cfg(feature = "sendmail-transport")] mod test { - use lettre::{EmailAddress, Envelope, SendableEmail, Transport}; use lettre::sendmail::SendmailTransport; + use lettre::{EmailAddress, Envelope, SendableEmail, Transport}; #[test] fn sendmail_transport_simple() { diff --git a/lettre/tests/transport_stub.rs b/lettre/tests/transport_stub.rs index 54b8c34..1265952 100644 --- a/lettre/tests/transport_stub.rs +++ b/lettre/tests/transport_stub.rs @@ -1,7 +1,7 @@ extern crate lettre; -use lettre::{EmailAddress, Envelope, SendableEmail, Transport}; use lettre::stub::StubTransport; +use lettre::{EmailAddress, Envelope, SendableEmail, Transport}; #[test] fn stub_transport() { diff --git a/lettre_email/src/lib.rs b/lettre_email/src/lib.rs index 8bdbdf9..3ee69e3 100644 --- a/lettre_email/src/lib.rs +++ b/lettre_email/src/lib.rs @@ -22,9 +22,9 @@ use mime::Mime; use std::fs::File; use std::io::Read; use std::path::Path; +use std::str::FromStr; use time::{now, Tm}; use uuid::Uuid; -use std::str::FromStr; /// Builds a `MimeMessage` structure #[derive(PartialEq, Eq, Clone, Debug)] diff --git a/lettre_email/tests/skeptic.rs b/lettre_email/tests/skeptic.rs index f5f82a8..0d8a896 100644 --- a/lettre_email/tests/skeptic.rs +++ b/lettre_email/tests/skeptic.rs @@ -1,8 +1,8 @@ extern crate glob; use self::glob::glob; -use std::env::consts::EXE_EXTENSION; use std::env; +use std::env::consts::EXE_EXTENSION; use std::path::Path; use std::process::Command;