Skip to content

Commit

Permalink
fix: make clippy happy
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Sep 23, 2024
1 parent 56e4073 commit cf57553
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 3 additions & 3 deletions foyer-storage/src/small/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ impl SetStorage {
&self.bloom_filter
}

#[allow(dead_code)]
#[cfg_attr(not(test), expect(dead_code))]
pub fn len(&self) -> usize {
self.len
}

#[allow(dead_code)]
#[cfg_attr(not(test), expect(dead_code))]
pub fn is_empty(&self) -> bool {
self.len == 0
}
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<'a> SetEntry<'a> {
}

/// Range of the entry in the set data.
#[allow(unused)]
#[expect(unused)]
pub fn range(&self) -> Range<usize> {
self.offset..self.offset + self.len()
}
Expand Down
26 changes: 24 additions & 2 deletions foyer-storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl FromStr for Engine {
}

if s.starts_with(MIXED_PREFIX) && s.ends_with(MIXED_SUFFIX) {
if let Ok(ratio) = (&s[MIXED_PREFIX.len()..s.len() - MIXED_SUFFIX.len()]).parse::<f64>() {
if let Ok(ratio) = s[MIXED_PREFIX.len()..s.len() - MIXED_SUFFIX.len()].parse::<f64>() {
return Ok(Engine::Mixed(ratio));
}
}
Expand Down Expand Up @@ -411,7 +411,7 @@ where
{
/// Setup disk cache store for the given in-memory cache.
pub fn new(memory: Cache<K, V, S>, engine: Engine) -> Self {
if matches!(engine, Engine::Mixed(ratio) if ratio <0.0 && ratio > 1.0) {
if matches!(engine, Engine::Mixed(ratio) if !(0.0..=1.0).contains(&ratio)) {
panic!("mixed engine small object disk cache ratio must be a f64 in range [0.0, 1.0]");
}

Expand Down Expand Up @@ -729,6 +729,17 @@ where
_marker: PhantomData<(K, V, S)>,
}

impl<K, V, S> Default for LargeEngineOptions<K, V, S>
where
K: StorageKey,
V: StorageValue,
S: HashBuilder + Debug,
{
fn default() -> Self {
Self::new()
}
}

impl<K, V, S> LargeEngineOptions<K, V, S>
where
K: StorageKey,
Expand Down Expand Up @@ -879,6 +890,17 @@ where
_marker: PhantomData<(K, V, S)>,
}

impl<K, V, S> Default for SmallEngineOptions<K, V, S>
where
K: StorageKey,
V: StorageValue,
S: HashBuilder + Debug,
{
fn default() -> Self {
Self::new()
}
}

/// Create small object disk cache engine default options.
impl<K, V, S> SmallEngineOptions<K, V, S>
where
Expand Down

0 comments on commit cf57553

Please sign in to comment.