Skip to content

Commit 5f447bb

Browse files
jplatteHywan
authored andcommitted
chore: Fix new clippy lints
1 parent 94e7ddd commit 5f447bb

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

crates/matrix-sdk-common/src/failures_cache.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ where
102102
Q: Hash + Eq + ?Sized,
103103
{
104104
let lock = self.inner.items.read();
105-
106-
let contains = if let Some(item) = lock.get(key) { !item.expired() } else { false };
107-
108-
contains
105+
if let Some(item) = lock.get(key) { !item.expired() } else { false }
109106
}
110107

111108
/// Get the failure count for a given key.

crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ pub fn from_last_chunk<const CAP: usize, Item, Gap>(
3434
// Check consistency before creating the `LinkedChunk`.
3535
{
3636
// The number of items is not too large.
37-
if let ChunkContent::Items(items) = &chunk.content {
38-
if items.len() > CAP {
39-
return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier });
40-
}
37+
if let ChunkContent::Items(items) = &chunk.content
38+
&& items.len() > CAP
39+
{
40+
return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier });
4141
}
4242

4343
// Chunk has no next chunk.
@@ -80,20 +80,20 @@ where
8080
// Check `LinkedChunk` is going to be consistent after the insertion.
8181
{
8282
// The number of items is not too large.
83-
if let ChunkContent::Items(items) = &new_first_chunk.content {
84-
if items.len() > CAP {
85-
return Err(LazyLoaderError::ChunkTooLarge { id: new_first_chunk.identifier });
86-
}
83+
if let ChunkContent::Items(items) = &new_first_chunk.content
84+
&& items.len() > CAP
85+
{
86+
return Err(LazyLoaderError::ChunkTooLarge { id: new_first_chunk.identifier });
8787
}
8888

8989
// New chunk doesn't create a cycle.
90-
if let Some(previous_chunk) = new_first_chunk.previous {
91-
if linked_chunk.chunks().any(|chunk| chunk.identifier() == previous_chunk) {
92-
return Err(LazyLoaderError::Cycle {
93-
new_chunk: new_first_chunk.identifier,
94-
with_chunk: previous_chunk,
95-
});
96-
}
90+
if let Some(previous_chunk) = new_first_chunk.previous
91+
&& linked_chunk.chunks().any(|chunk| chunk.identifier() == previous_chunk)
92+
{
93+
return Err(LazyLoaderError::Cycle {
94+
new_chunk: new_first_chunk.identifier,
95+
with_chunk: previous_chunk,
96+
});
9797
}
9898

9999
let first_chunk = linked_chunk.links.first_chunk();
@@ -233,10 +233,10 @@ where
233233

234234
// Check consistency before replacing the `LinkedChunk`.
235235
// The number of items is not too large.
236-
if let ChunkContent::Items(items) = &chunk.content {
237-
if items.len() > CAP {
238-
return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier });
239-
}
236+
if let ChunkContent::Items(items) = &chunk.content
237+
&& items.len() > CAP
238+
{
239+
return Err(LazyLoaderError::ChunkTooLarge { id: chunk.identifier });
240240
}
241241

242242
// Chunk has no next chunk.

crates/matrix-sdk-common/src/ttl_cache.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ where
5959
Q: Hash + Eq + ?Sized,
6060
{
6161
let cache = &self.items;
62-
let contains = if let Some(item) = cache.get(key) { !item.expired() } else { false };
63-
64-
contains
62+
if let Some(item) = cache.get(key) { !item.expired() } else { false }
6563
}
6664

6765
/// Add a single item to the cache.

0 commit comments

Comments
 (0)