chore: Fix new clippy lints

This commit is contained in:
Jonas Platte
2025-08-05 21:49:57 +02:00
committed by Ivan Enderlin
parent 94e7ddd1ab
commit 5f447bbb17
3 changed files with 21 additions and 26 deletions

View File

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

View File

@@ -34,10 +34,10 @@ pub fn from_last_chunk<const CAP: usize, Item, Gap>(
// 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.

View File

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