chore: fix clippy warnings

This commit is contained in:
link2xt
2026-03-24 11:23:53 +01:00
committed by l
parent 2637c3bea4
commit ebe8550c52
8 changed files with 22 additions and 38 deletions

View File

@@ -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(())

View File

@@ -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: std::io::BufRead>(
}
}
}
"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,
_ => {}

View File

@@ -881,7 +881,7 @@ fn merge_with_cache(
) -> Vec<SocketAddr> {
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 {

View File

@@ -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(&quota.modified) < Duration::from_secs(ratelimit_secs))
.is_none()
quota.get(&transport_id).is_none_or(|quota| {
time_elapsed(&quota.modified) >= Duration::from_secs(ratelimit_secs)
})
}
/// Updates `quota.recent`, sets `quota.modified` to the current time

View File

@@ -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);
};

View File

@@ -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(

View File

@@ -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)

View File

@@ -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);
}
_ => (),
}