From 5f447bbb17cdef918a45885cccd378b861e30daa Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 5 Aug 2025 21:49:57 +0200 Subject: [PATCH] chore: Fix new clippy lints --- .../matrix-sdk-common/src/failures_cache.rs | 5 +-- .../src/linked_chunk/lazy_loader.rs | 38 +++++++++---------- crates/matrix-sdk-common/src/ttl_cache.rs | 4 +- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/crates/matrix-sdk-common/src/failures_cache.rs b/crates/matrix-sdk-common/src/failures_cache.rs index 84bb26665..151d0866c 100644 --- a/crates/matrix-sdk-common/src/failures_cache.rs +++ b/crates/matrix-sdk-common/src/failures_cache.rs @@ -102,10 +102,7 @@ where Q: Hash + Eq + ?Sized, { let lock = self.inner.items.read(); - - let contains = if let Some(item) = lock.get(key) { !item.expired() } else { false }; - - contains + if let Some(item) = lock.get(key) { !item.expired() } else { false } } /// Get the failure count for a given key. diff --git a/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs b/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs index dcb00b496..8db1c4a29 100644 --- a/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs +++ b/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs @@ -34,10 +34,10 @@ pub fn from_last_chunk( // Check consistency before creating the `LinkedChunk`. { // The number of items is not too large. - if let ChunkContent::Items(items) = &chunk.content { - if items.len() > CAP { - return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier }); - } + if let ChunkContent::Items(items) = &chunk.content + && items.len() > CAP + { + return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier }); } // Chunk has no next chunk. @@ -80,20 +80,20 @@ where // Check `LinkedChunk` is going to be consistent after the insertion. { // The number of items is not too large. - if let ChunkContent::Items(items) = &new_first_chunk.content { - if items.len() > CAP { - return Err(LazyLoaderError::ChunkTooLarge { id: new_first_chunk.identifier }); - } + if let ChunkContent::Items(items) = &new_first_chunk.content + && items.len() > CAP + { + return Err(LazyLoaderError::ChunkTooLarge { id: new_first_chunk.identifier }); } // New chunk doesn't create a cycle. - if let Some(previous_chunk) = new_first_chunk.previous { - if linked_chunk.chunks().any(|chunk| chunk.identifier() == previous_chunk) { - return Err(LazyLoaderError::Cycle { - new_chunk: new_first_chunk.identifier, - with_chunk: previous_chunk, - }); - } + if let Some(previous_chunk) = new_first_chunk.previous + && linked_chunk.chunks().any(|chunk| chunk.identifier() == previous_chunk) + { + return Err(LazyLoaderError::Cycle { + new_chunk: new_first_chunk.identifier, + with_chunk: previous_chunk, + }); } let first_chunk = linked_chunk.links.first_chunk(); @@ -233,10 +233,10 @@ where // Check consistency before replacing the `LinkedChunk`. // The number of items is not too large. - if let ChunkContent::Items(items) = &chunk.content { - if items.len() > CAP { - return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier }); - } + if let ChunkContent::Items(items) = &chunk.content + && items.len() > CAP + { + return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier }); } // Chunk has no next chunk. diff --git a/crates/matrix-sdk-common/src/ttl_cache.rs b/crates/matrix-sdk-common/src/ttl_cache.rs index 317699bbe..e39d486eb 100644 --- a/crates/matrix-sdk-common/src/ttl_cache.rs +++ b/crates/matrix-sdk-common/src/ttl_cache.rs @@ -59,9 +59,7 @@ where Q: Hash + Eq + ?Sized, { let cache = &self.items; - let contains = if let Some(item) = cache.get(key) { !item.expired() } else { false }; - - contains + if let Some(item) = cache.get(key) { !item.expired() } else { false } } /// Add a single item to the cache.