From 139fbfae85afdb14d69da3cdccbf837534a6570c Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 17 Jun 2025 21:35:13 +0000 Subject: [PATCH] chore: nightly clippy fixes --- deltachat-contact-tools/src/lib.rs | 4 ++-- deltachat-ffi/src/lot.rs | 4 ++-- deltachat-repl/src/cmdline.rs | 2 +- deltachat-repl/src/main.rs | 16 ++++++++-------- deltachat-rpc-server/src/main.rs | 6 +++--- src/chat.rs | 6 +++--- src/contact.rs | 2 +- src/ephemeral.rs | 2 +- src/headerdef.rs | 4 ++-- src/imap.rs | 2 +- src/message.rs | 2 +- src/summary.rs | 2 +- src/tools.rs | 2 +- src/webxdc.rs | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/deltachat-contact-tools/src/lib.rs b/deltachat-contact-tools/src/lib.rs index 86e947d67..d9264ebf6 100644 --- a/deltachat-contact-tools/src/lib.rs +++ b/deltachat-contact-tools/src/lib.rs @@ -76,7 +76,7 @@ impl ContactAddress { /// Allow converting [`ContactAddress`] to an SQLite type. impl rusqlite::types::ToSql for ContactAddress { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Text(self.0.to_string()); let out = rusqlite::types::ToSqlOutput::Owned(val); Ok(out) @@ -282,7 +282,7 @@ impl EmailAddress { } impl rusqlite::types::ToSql for EmailAddress { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Text(self.to_string()); let out = rusqlite::types::ToSqlOutput::Owned(val); Ok(out) diff --git a/deltachat-ffi/src/lot.rs b/deltachat-ffi/src/lot.rs index 0649b4ec2..e77483ef7 100644 --- a/deltachat-ffi/src/lot.rs +++ b/deltachat-ffi/src/lot.rs @@ -34,7 +34,7 @@ pub enum Meaning { } impl Lot { - pub fn get_text1(&self) -> Option> { + pub fn get_text1(&self) -> Option> { match self { Self::Summary(summary) => match &summary.prefix { None => None, @@ -66,7 +66,7 @@ impl Lot { } } - pub fn get_text2(&self) -> Option> { + pub fn get_text2(&self) -> Option> { match self { Self::Summary(summary) => Some(summary.truncated_text(160)), Self::Qr(_) => None, diff --git a/deltachat-repl/src/cmdline.rs b/deltachat-repl/src/cmdline.rs index 0aceb14b8..84d6aae76 100644 --- a/deltachat-repl/src/cmdline.rs +++ b/deltachat-repl/src/cmdline.rs @@ -493,7 +493,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu "send-backup" => { let provider = BackupProvider::prepare(&context).await?; let qr = format_backup(&provider.qr())?; - println!("QR code: {}", qr); + println!("QR code: {qr}"); qr2term::print_qr(qr.as_str())?; provider.await?; } diff --git a/deltachat-repl/src/main.rs b/deltachat-repl/src/main.rs index 8d3dfc3eb..4d6b37780 100644 --- a/deltachat-repl/src/main.rs +++ b/deltachat-repl/src/main.rs @@ -41,25 +41,25 @@ fn receive_event(event: EventType) { match event { EventType::Info(msg) => { /* do not show the event as this would fill the screen */ - info!("{}", msg); + info!("{msg}"); } EventType::SmtpConnected(msg) => { - info!("[SMTP_CONNECTED] {}", msg); + info!("[SMTP_CONNECTED] {msg}"); } EventType::ImapConnected(msg) => { - info!("[IMAP_CONNECTED] {}", msg); + info!("[IMAP_CONNECTED] {msg}"); } EventType::SmtpMessageSent(msg) => { - info!("[SMTP_MESSAGE_SENT] {}", msg); + info!("[SMTP_MESSAGE_SENT] {msg}"); } EventType::Warning(msg) => { - warn!("{}", msg); + warn!("{msg}"); } EventType::Error(msg) => { - error!("{}", msg); + error!("{msg}"); } EventType::ErrorSelfNotInGroup(msg) => { - error!("[SELF_NOT_IN_GROUP] {}", msg); + error!("[SELF_NOT_IN_GROUP] {msg}"); } EventType::MsgsChanged { chat_id, msg_id } => { info!( @@ -124,7 +124,7 @@ fn receive_event(event: EventType) { ); } _ => { - info!("Received {:?}", event); + info!("Received {event:?}"); } } } diff --git a/deltachat-rpc-server/src/main.rs b/deltachat-rpc-server/src/main.rs index 66f9da93a..3381f2c8d 100644 --- a/deltachat-rpc-server/src/main.rs +++ b/deltachat-rpc-server/src/main.rs @@ -73,7 +73,7 @@ async fn main_impl() -> Result<()> { .init(); let path = std::env::var("DC_ACCOUNTS_PATH").unwrap_or_else(|_| "accounts".to_string()); - log::info!("Starting with accounts directory `{}`.", path); + log::info!("Starting with accounts directory `{path}`."); let writable = true; let accounts = Accounts::new(PathBuf::from(&path), writable).await?; @@ -97,7 +97,7 @@ async fn main_impl() -> Result<()> { Some(message) => serde_json::to_string(&message)?, } }; - log::trace!("RPC send {}", message); + log::trace!("RPC send {message}"); println!("{message}"); } Ok(()) @@ -141,7 +141,7 @@ async fn main_impl() -> Result<()> { Some(message) => message, } }; - log::trace!("RPC recv {}", message); + log::trace!("RPC recv {message}"); let session = session.clone(); tokio::spawn(async move { session.handle_incoming(&message).await; diff --git a/src/chat.rs b/src/chat.rs index e940d1178..70ba606a9 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1508,7 +1508,7 @@ impl std::fmt::Display for ChatId { /// This allows you to directly store [ChatId] into the database as /// well as query for a [ChatId]. impl rusqlite::types::ToSql for ChatId { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Integer(i64::from(self.0)); let out = rusqlite::types::ToSqlOutput::Owned(val); Ok(out) @@ -2380,7 +2380,7 @@ pub enum ChatVisibility { } impl rusqlite::types::ToSql for ChatVisibility { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Integer(*self as i64); let out = rusqlite::types::ToSqlOutput::Owned(val); Ok(out) @@ -4026,7 +4026,7 @@ pub enum MuteDuration { } impl rusqlite::types::ToSql for MuteDuration { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let duration: i64 = match &self { MuteDuration::NotMuted => 0, MuteDuration::Forever => -1, diff --git a/src/contact.rs b/src/contact.rs index bb683bd8c..7889224bd 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -243,7 +243,7 @@ impl fmt::Display for ContactId { /// Allow converting [`ContactId`] to an SQLite type. impl rusqlite::types::ToSql for ContactId { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Integer(i64::from(self.0)); let out = rusqlite::types::ToSqlOutput::Owned(val); Ok(out) diff --git a/src/ephemeral.rs b/src/ephemeral.rs index 29143089b..9f2583e01 100644 --- a/src/ephemeral.rs +++ b/src/ephemeral.rs @@ -146,7 +146,7 @@ impl FromStr for Timer { } impl rusqlite::types::ToSql for Timer { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Integer(match self { Self::Disabled => 0, Self::Enabled { duration } => i64::from(*duration), diff --git a/src/headerdef.rs b/src/headerdef.rs index cc49fa9a2..6cfd61af6 100644 --- a/src/headerdef.rs +++ b/src/headerdef.rs @@ -134,14 +134,14 @@ pub trait HeaderDefMap { fn get_header_value(&self, headerdef: HeaderDef) -> Option; /// Returns requested header if it exists. - fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader>; + fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader<'_>>; } impl HeaderDefMap for [MailHeader<'_>] { fn get_header_value(&self, headerdef: HeaderDef) -> Option { self.get_first_value(headerdef.get_headername()) } - fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader> { + fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader<'_>> { self.get_first_header(headerdef.get_headername()) } } diff --git a/src/imap.rs b/src/imap.rs index dfc53525c..c0ef6d3e6 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -2163,7 +2163,7 @@ pub(crate) fn get_folder_meaning(folder: &Name) -> FolderMeaning { } /// Parses the headers from the FETCH result. -fn get_fetch_headers(prefetch_msg: &Fetch) -> Result> { +fn get_fetch_headers(prefetch_msg: &Fetch) -> Result>> { match prefetch_msg.header() { Some(header_bytes) => { let (headers, _) = mailparse::parse_headers(header_bytes)?; diff --git a/src/message.rs b/src/message.rs index 5e5192446..d782366b8 100644 --- a/src/message.rs +++ b/src/message.rs @@ -361,7 +361,7 @@ impl std::fmt::Display for MsgId { /// This **does** ensure that no special message IDs are written into /// the database and the conversion will fail if this is not the case. impl rusqlite::types::ToSql for MsgId { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { if self.0 <= DC_MSG_ID_LAST_SPECIAL { return Err(rusqlite::Error::ToSqlConversionFailure( format_err!("Invalid MsgId {}", self.0).into(), diff --git a/src/summary.rs b/src/summary.rs index 027348e16..c420e976e 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -146,7 +146,7 @@ impl Summary { } /// Returns the [`Summary::text`] attribute truncated to an approximate length. - pub fn truncated_text(&self, approx_chars: usize) -> Cow { + pub fn truncated_text(&self, approx_chars: usize) -> Cow<'_, str> { truncate(&self.text, approx_chars) } } diff --git a/src/tools.rs b/src/tools.rs index 58b176c21..9a971ce61 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -46,7 +46,7 @@ use crate::stock_str; /// Shortens a string to a specified length and adds "[...]" to the /// end of the shortened string. -pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow { +pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow<'_, str> { let count = buf.chars().count(); if count <= approx_chars + DC_ELLIPSIS.len() { return Cow::Borrowed(buf); diff --git a/src/webxdc.rs b/src/webxdc.rs index ecc4d58f9..8a0b82dc7 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -157,7 +157,7 @@ impl StatusUpdateSerial { } impl rusqlite::types::ToSql for StatusUpdateSerial { - fn to_sql(&self) -> rusqlite::Result { + fn to_sql(&self) -> rusqlite::Result> { let val = rusqlite::types::Value::Integer(i64::from(self.0)); let out = rusqlite::types::ToSqlOutput::Owned(val); Ok(out)