From 24baf67e2612a5e9496b91eb1c26a8a01ed68048 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Fri, 22 Nov 2024 19:57:38 +0100 Subject: [PATCH] chore(clippy): fix some pedantic lints --- src/body/base64.rs | 2 +- src/headers/rfc2047.rs | 2 +- src/headers/rfc2231.rs | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/body/base64.rs b/src/body/base64.rs index d799ec6..adb9172 100644 --- a/src/body/base64.rs +++ b/src/body/base64.rs @@ -46,7 +46,7 @@ pub fn encode(b: &[u8], w: &mut dyn Write) -> fmt::Result { while let Some(chunk) = chunks.next() { let len = ::base64::engine::general_purpose::STANDARD .encode_slice(chunk, &mut buf) - .unwrap(); + .expect("base64 output `buf` is not big enough"); w.write_str(str::from_utf8(&buf[..len]).expect("base64 produced an invalid encode"))?; if chunks.peek().is_some() { diff --git a/src/headers/rfc2047.rs b/src/headers/rfc2047.rs index b089b7c..0bfabe1 100644 --- a/src/headers/rfc2047.rs +++ b/src/headers/rfc2047.rs @@ -54,7 +54,7 @@ pub fn encode(mut s: &str, w: &mut EmailWriter<'_>) -> fmt::Result { // No space remaining, but going to a new line will require us // to introduce a new space, which will mess up things even more. - word = &s[..s.chars().next().unwrap().len_utf8()]; + word = &s[..s.chars().next().expect("`s` is empty").len_utf8()]; } // Write the prefix diff --git a/src/headers/rfc2231.rs b/src/headers/rfc2231.rs index e37c984..ef6973a 100644 --- a/src/headers/rfc2231.rs +++ b/src/headers/rfc2231.rs @@ -105,15 +105,15 @@ pub fn encode(key: &str, mut value: &str, w: &mut EmailWriter<'_>) -> fmt::Resul w.write_char('"')?; - if !value.is_empty() { - // End of line - w.write_char(';')?; - w.new_line()?; - } else { + if value.is_empty() { // End of value break; } + // End of line + w.write_char(';')?; + w.new_line()?; + i += 1; } } @@ -144,15 +144,15 @@ pub fn encode(key: &str, mut value: &str, w: &mut EmailWriter<'_>) -> fmt::Resul } } - if !value.is_empty() { - // End of line - w.write_char(';')?; - w.new_line()?; - } else { + if value.is_empty() { // End of value break; } + // End of line + w.write_char(';')?; + w.new_line()?; + i += 1; } }