clippy: fix latest warnings (#855)

This commit is contained in:
Paolo Barbolini
2023-01-29 14:46:57 +01:00
committed by GitHub
parent cc25223914
commit f8f19d6af5
23 changed files with 49 additions and 50 deletions

View File

@@ -27,6 +27,6 @@ async fn main() {
// Send the email
match mailer.send(email).await {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -27,6 +27,6 @@ async fn main() {
// Send the email
match mailer.send(email).await {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -17,6 +17,6 @@ fn main() {
// Send the email
match mailer.send(&email) {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -39,6 +39,6 @@ fn main() {
// Send the email
match mailer.send(&email) {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -22,6 +22,6 @@ fn main() {
// Send the email
match mailer.send(&email) {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -22,6 +22,6 @@ fn main() {
// Send the email
match mailer.send(&email) {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -31,6 +31,6 @@ async fn main() {
// Send the email
match mailer.send(email).await {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -31,6 +31,6 @@ async fn main() {
// Send the email
match mailer.send(email).await {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
Err(e) => panic!("Could not send email: {e:?}"),
}
}

View File

@@ -184,7 +184,7 @@ where
let domain = domain.as_ref();
Address::check_domain(domain)?;
let serialized = format!("{}@{}", user, domain);
let serialized = format!("{user}@{domain}");
Ok(Address {
serialized,
at_start: user.len(),

View File

@@ -96,7 +96,7 @@ impl Attachment {
builder.header(header::ContentDisposition::attachment(&filename))
}
Disposition::Inline(content_id) => builder
.header(header::ContentId::from(format!("<{}>", content_id)))
.header(header::ContentId::from(format!("<{content_id}>")))
.header(header::ContentDisposition::inline()),
};
builder = builder.header(content_type);

View File

@@ -588,7 +588,7 @@ cJ5Ku0OTwRtSMaseRPX+T4EfG1Caa/eunPPN4rh+CSup2BVVarOT
);
let signed = message.formatted();
let signed = std::str::from_utf8(&signed).unwrap();
println!("{}", signed);
println!("{signed}");
assert_eq!(
signed,
std::concat!(

View File

@@ -33,7 +33,7 @@ impl ContentDisposition {
}
fn with_name(kind: &str, file_name: &str) -> Self {
let raw_value = format!("{}; filename=\"{}\"", kind, file_name);
let raw_value = format!("{kind}; filename=\"{file_name}\"");
let mut encoded_value = String::new();
let line_len = "Content-Disposition: ".len();
@@ -90,12 +90,12 @@ mod test {
headers.set(ContentDisposition::inline());
assert_eq!(format!("{}", headers), "Content-Disposition: inline\r\n");
assert_eq!(format!("{headers}"), "Content-Disposition: inline\r\n");
headers.set(ContentDisposition::attachment("something.txt"));
assert_eq!(
format!("{}", headers),
format!("{headers}"),
"Content-Disposition: attachment; filename=\"something.txt\"\r\n"
);
}

View File

@@ -135,8 +135,7 @@ mod serde {
match ContentType::parse(mime) {
Ok(content_type) => Ok(content_type),
Err(_) => Err(E::custom(format!(
"Couldn't parse the following MIME-Type: {}",
mime
"Couldn't parse the following MIME-Type: {mime}"
))),
}
}

View File

@@ -190,9 +190,9 @@ impl MultiPartKind {
},
boundary,
match self {
Self::Encrypted { protocol } => format!("; protocol=\"{}\"", protocol),
Self::Encrypted { protocol } => format!("; protocol=\"{protocol}\""),
Self::Signed { protocol, micalg } =>
format!("; protocol=\"{}\"; micalg=\"{}\"", protocol, micalg),
format!("; protocol=\"{protocol}\"; micalg=\"{micalg}\""),
_ => String::new(),
}
)

View File

@@ -71,7 +71,7 @@ impl fmt::Display for Error {
};
if let Some(ref e) = self.inner.source {
write!(f, ": {}", e)?;
write!(f, ": {e}")?;
}
Ok(())

View File

@@ -208,10 +208,10 @@ impl FileTransport {
pub fn read(&self, email_id: &str) -> Result<(Envelope, Vec<u8>), Error> {
use std::fs;
let eml_file = self.path.join(format!("{}.eml", email_id));
let eml_file = self.path.join(format!("{email_id}.eml"));
let eml = fs::read(eml_file).map_err(error::io)?;
let json_file = self.path.join(format!("{}.json", email_id));
let json_file = self.path.join(format!("{email_id}.json"));
let json = fs::read(json_file).map_err(error::io)?;
let envelope = serde_json::from_slice(&json).map_err(error::envelope)?;
@@ -219,7 +219,7 @@ impl FileTransport {
}
fn path(&self, email_id: &Uuid, extension: &str) -> PathBuf {
self.path.join(format!("{}.{}", email_id, extension))
self.path.join(format!("{email_id}.{extension}"))
}
}
@@ -255,10 +255,10 @@ where
/// Reads the envelope and the raw message content.
#[cfg(feature = "file-transport-envelope")]
pub async fn read(&self, email_id: &str) -> Result<(Envelope, Vec<u8>), Error> {
let eml_file = self.inner.path.join(format!("{}.eml", email_id));
let eml_file = self.inner.path.join(format!("{email_id}.eml"));
let eml = E::fs_read(&eml_file).await.map_err(error::io)?;
let json_file = self.inner.path.join(format!("{}.json", email_id));
let json_file = self.inner.path.join(format!("{email_id}.json"));
let json = E::fs_read(&json_file).await.map_err(error::io)?;
let envelope = serde_json::from_slice(&json).map_err(error::envelope)?;

View File

@@ -68,7 +68,7 @@ impl fmt::Display for Error {
};
if let Some(ref e) = self.inner.source {
write!(f, ": {}", e)?;
write!(f, ": {e}")?;
}
Ok(())

View File

@@ -59,7 +59,7 @@ impl Display for Mail {
self.sender.as_ref().map_or("", |s| s.as_ref())
)?;
for parameter in &self.parameters {
write!(f, " {}", parameter)?;
write!(f, " {parameter}")?;
}
f.write_str("\r\n")
}
@@ -84,7 +84,7 @@ impl Display for Rcpt {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "RCPT TO:<{}>", self.recipient)?;
for parameter in &self.parameters {
write!(f, " {}", parameter)?;
write!(f, " {parameter}")?;
}
f.write_str("\r\n")
}
@@ -144,7 +144,7 @@ impl Display for Help {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("HELP")?;
if let Some(argument) = &self.argument {
write!(f, " {}", argument)?;
write!(f, " {argument}")?;
}
f.write_str("\r\n")
}
@@ -341,9 +341,9 @@ mod test {
format!("{}", Rcpt::new(email, vec![rcpt_parameter])),
"RCPT TO:<test@example.com> TEST=value\r\n"
);
assert_eq!(format!("{}", Quit), "QUIT\r\n");
assert_eq!(format!("{}", Data), "DATA\r\n");
assert_eq!(format!("{}", Noop), "NOOP\r\n");
assert_eq!(format!("{Quit}"), "QUIT\r\n");
assert_eq!(format!("{Data}"), "DATA\r\n");
assert_eq!(format!("{Noop}"), "NOOP\r\n");
assert_eq!(format!("{}", Help::new(None)), "HELP\r\n");
assert_eq!(
format!("{}", Help::new(Some("test".to_string()))),
@@ -357,7 +357,7 @@ mod test {
format!("{}", Expn::new("test".to_string())),
"EXPN test\r\n"
);
assert_eq!(format!("{}", Rset), "RSET\r\n");
assert_eq!(format!("{Rset}"), "RSET\r\n");
let credentials = Credentials::new("user".to_string(), "password".to_string());
assert_eq!(
format!(

View File

@@ -137,15 +137,15 @@ impl fmt::Display for Error {
#[cfg(any(feature = "native-tls", feature = "rustls-tls", feature = "boring-tls"))]
Kind::Tls => f.write_str("tls error")?,
Kind::Transient(ref code) => {
write!(f, "transient error ({})", code)?;
write!(f, "transient error ({code})")?;
}
Kind::Permanent(ref code) => {
write!(f, "permanent error ({})", code)?;
write!(f, "permanent error ({code})")?;
}
};
if let Some(ref e) = self.inner.source {
write!(f, ": {}", e)?;
write!(f, ": {e}")?;
}
Ok(())

View File

@@ -55,8 +55,8 @@ impl Display for ClientId {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
Self::Domain(ref value) => f.write_str(value),
Self::Ipv4(ref value) => write!(f, "[{}]", value),
Self::Ipv6(ref value) => write!(f, "[IPv6:{}]", value),
Self::Ipv4(ref value) => write!(f, "[{value}]"),
Self::Ipv6(ref value) => write!(f, "[IPv6:{value}]"),
}
}
}
@@ -97,7 +97,7 @@ impl Display for Extension {
Extension::EightBitMime => f.write_str("8BITMIME"),
Extension::SmtpUtfEight => f.write_str("SMTPUTF8"),
Extension::StartTls => f.write_str("STARTTLS"),
Extension::Authentication(ref mechanism) => write!(f, "AUTH {}", mechanism),
Extension::Authentication(ref mechanism) => write!(f, "AUTH {mechanism}"),
}
}
}
@@ -228,8 +228,8 @@ pub enum MailParameter {
impl Display for MailParameter {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
MailParameter::Body(ref value) => write!(f, "BODY={}", value),
MailParameter::Size(size) => write!(f, "SIZE={}", size),
MailParameter::Body(ref value) => write!(f, "BODY={value}"),
MailParameter::Size(size) => write!(f, "SIZE={size}"),
MailParameter::SmtpUtfEight => f.write_str("SMTPUTF8"),
MailParameter::Other {
ref keyword,
@@ -307,7 +307,7 @@ mod test {
format!("{}", ClientId::Domain("test".to_string())),
"test".to_string()
);
assert_eq!(format!("{}", LOCALHOST_CLIENT), "[127.0.0.1]".to_string());
assert_eq!(format!("{LOCALHOST_CLIENT}"), "[127.0.0.1]".to_string());
}
#[test]

View File

@@ -494,7 +494,7 @@ mod test {
let res = parse_response(raw_response);
match res {
Err(nom::Err::Incomplete(_)) => {}
_ => panic!("Expected incomplete response, got {:?}", res),
_ => panic!("Expected incomplete response, got {res:?}"),
}
}

View File

@@ -33,7 +33,7 @@ mod sync {
let result = sender.send(&email);
let id = result.unwrap();
let eml_file = temp_dir().join(format!("{}.eml", id));
let eml_file = temp_dir().join(format!("{id}.eml"));
let eml = read_to_string(&eml_file).unwrap();
assert_eq!(
@@ -68,10 +68,10 @@ mod sync {
let result = sender.send(&email);
let id = result.unwrap();
let eml_file = temp_dir().join(format!("{}.eml", id));
let eml_file = temp_dir().join(format!("{id}.eml"));
let eml = read_to_string(&eml_file).unwrap();
let json_file = temp_dir().join(format!("{}.json", id));
let json_file = temp_dir().join(format!("{id}.json"));
let json = read_to_string(&json_file).unwrap();
assert_eq!(
@@ -131,7 +131,7 @@ mod tokio_1 {
let result = sender.send(email).await;
let id = result.unwrap();
let eml_file = temp_dir().join(format!("{}.eml", id));
let eml_file = temp_dir().join(format!("{id}.eml"));
let eml = read_to_string(&eml_file).unwrap();
assert_eq!(
@@ -182,7 +182,7 @@ mod asyncstd_1 {
let result = sender.send(email).await;
let id = result.unwrap();
let eml_file = temp_dir().join(format!("{}.eml", id));
let eml_file = temp_dir().join(format!("{id}.eml"));
let eml = read_to_string(&eml_file).unwrap();
assert_eq!(

View File

@@ -15,7 +15,7 @@ mod sync {
.unwrap();
let result = sender.send(&email);
println!("{:?}", result);
println!("{result:?}");
assert!(result.is_ok());
}
}
@@ -42,7 +42,7 @@ mod tokio_1 {
.unwrap();
let result = sender.send(email).await;
println!("{:?}", result);
println!("{result:?}");
assert!(result.is_ok());
}
}
@@ -68,7 +68,7 @@ mod asyncstd_1 {
.unwrap();
let result = sender.send(email).await;
println!("{:?}", result);
println!("{result:?}");
assert!(result.is_ok());
}
}