diff --git a/src/config/config_tests.rs b/src/config/config_tests.rs index 9a1a8f2c5..c8a4029e3 100644 --- a/src/config/config_tests.rs +++ b/src/config/config_tests.rs @@ -246,8 +246,7 @@ async fn test_sync() -> Result<()> { alice1 .get_config(Config::Selfavatar) .await? - .filter(|path| path.ends_with(".png")) - .is_some() + .is_some_and(|path| path.ends_with(".png")) ); alice0.set_config(Config::Selfavatar, None).await?; sync(&alice0, &alice1).await; @@ -305,16 +304,14 @@ async fn test_no_sync_on_self_sent_msg() -> Result<()> { alice1 .get_config(Config::Selfavatar) .await? - .filter(|path| path.ends_with(".jpg")) - .is_some() + .is_some_and(|path| path.ends_with(".jpg")) ); sync(alice1, alice0).await; assert!( alice0 .get_config(Config::Selfavatar) .await? - .filter(|path| path.ends_with(".jpg")) - .is_some() + .is_some_and(|path| path.ends_with(".jpg")) ); Ok(()) diff --git a/src/dehtml.rs b/src/dehtml.rs index 4c1b6cc24..43ade717e 100644 --- a/src/dehtml.rs +++ b/src/dehtml.rs @@ -266,15 +266,11 @@ fn dehtml_endtag_cb(event: &BytesEnd, dehtml: &mut Dehtml) { } } } - "b" | "strong" => { - if dehtml.get_add_text() != AddText::No { - *dehtml.get_buf() += "*"; - } + "b" | "strong" if dehtml.get_add_text() != AddText::No => { + *dehtml.get_buf() += "*"; } - "i" | "em" => { - if dehtml.get_add_text() != AddText::No { - *dehtml.get_buf() += "_"; - } + "i" | "em" if dehtml.get_add_text() != AddText::No => { + *dehtml.get_buf() += "_"; } "blockquote" => pop_tag(&mut dehtml.blockquotes_since_blockquote), _ => {} @@ -341,15 +337,11 @@ fn dehtml_starttag_cb( } } } - "b" | "strong" => { - if dehtml.get_add_text() != AddText::No { - *dehtml.get_buf() += "*"; - } + "b" | "strong" if dehtml.get_add_text() != AddText::No => { + *dehtml.get_buf() += "*"; } - "i" | "em" => { - if dehtml.get_add_text() != AddText::No { - *dehtml.get_buf() += "_"; - } + "i" | "em" if dehtml.get_add_text() != AddText::No => { + *dehtml.get_buf() += "_"; } "blockquote" => dehtml.blockquotes_since_blockquote += 1, _ => {} diff --git a/src/net/dns.rs b/src/net/dns.rs index ac6956446..6ed3ce5e3 100644 --- a/src/net/dns.rs +++ b/src/net/dns.rs @@ -881,7 +881,7 @@ fn merge_with_cache( ) -> Vec { let rest = resolved_addrs.split_off(std::cmp::min(resolved_addrs.len(), 2)); - for addr in cache.into_iter().chain(rest.into_iter()) { + for addr in cache.into_iter().chain(rest) { if !resolved_addrs.contains(&addr) { resolved_addrs.push(addr); if resolved_addrs.len() >= 10 { diff --git a/src/quota.rs b/src/quota.rs index 6c34880c5..ec93f5877 100644 --- a/src/quota.rs +++ b/src/quota.rs @@ -109,10 +109,9 @@ impl Context { /// called. pub(crate) async fn quota_needs_update(&self, transport_id: u32, ratelimit_secs: u64) -> bool { let quota = self.quota.read().await; - quota - .get(&transport_id) - .filter(|quota| time_elapsed("a.modified) < Duration::from_secs(ratelimit_secs)) - .is_none() + quota.get(&transport_id).is_none_or(|quota| { + time_elapsed("a.modified) >= Duration::from_secs(ratelimit_secs) + }) } /// Updates `quota.recent`, sets `quota.modified` to the current time diff --git a/src/reaction.rs b/src/reaction.rs index 676b1cb5f..08f0494ef 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -347,8 +347,7 @@ impl Chat { if self .param .get_i64(Param::LastReactionTimestamp) - .filter(|&reaction_timestamp| reaction_timestamp > timestamp) - .is_none() + .is_none_or(|reaction_timestamp| reaction_timestamp <= timestamp) { return Ok(None); }; diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 249972024..55c98da76 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -879,8 +879,7 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1 let instance = if mime_parser .parts .first() - .filter(|part| part.typ == Viewtype::Webxdc) - .is_some() + .is_some_and(|part| part.typ == Viewtype::Webxdc) { can_info_msg = false; Some( diff --git a/src/scheduler.rs b/src/scheduler.rs index 53b5385bc..655b657e2 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -876,7 +876,7 @@ impl Scheduler { let timeout_duration = std::time::Duration::from_secs(30); let tracker = TaskTracker::new(); - for b in self.inboxes.into_iter().chain(self.oboxes.into_iter()) { + for b in self.inboxes.into_iter().chain(self.oboxes) { let context = context.clone(); tracker.spawn(async move { tokio::time::timeout(timeout_duration, b.handle) diff --git a/src/simplify.rs b/src/simplify.rs index b2168a37f..0e3c70865 100644 --- a/src/simplify.rs +++ b/src/simplify.rs @@ -34,12 +34,10 @@ pub(crate) fn remove_message_footer<'a>( // some providers encode `-- ` to `=2D-` which results in only `--`; // use that only when no other footer is found // and if the line before is empty and the line after is not empty - "--" => { - if (ix == 0 || lines.get(ix.saturating_sub(1)).is_none_or_empty()) - && !lines.get(ix + 1).is_none_or_empty() - { - nearly_standard_footer = Some(ix); - } + "--" if (ix == 0 || lines.get(ix.saturating_sub(1)).is_none_or_empty()) + && !lines.get(ix + 1).is_none_or_empty() => + { + nearly_standard_footer = Some(ix); } _ => (), }