Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
Signed-off-by: Chojan Shang <psiace@outlook.com>
  • Loading branch information
PsiACE committed Dec 17, 2020
1 parent 8f75e6a commit 4d431e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/cache.rs
Expand Up @@ -508,7 +508,7 @@ where
/// }
/// ```
///
pub fn insert(&mut self, k: K, v: V) -> Result<Option<V>, ()> {
pub fn insert(&mut self, k: K, v: V) -> Result<Option<V>, Option<()>> {
self.insert_with_ttl(k, v, Duration::from_secs(0))
}

Expand Down Expand Up @@ -538,7 +538,12 @@ where
/// assert!(!cache.contains(&1));
/// ```
///
pub fn insert_with_ttl(&mut self, k: K, v: V, expiration: Duration) -> Result<Option<V>, ()> {
pub fn insert_with_ttl(
&mut self,
k: K,
v: V,
expiration: Duration,
) -> Result<Option<V>, Option<()>> {
self.store.cleanup(&self.on_evict);

let key_hash = self.key_hash(&k);
Expand All @@ -561,7 +566,7 @@ where
}
Err(victim) => {
self.remove_victim(victim);
Err(())
Err(Some(()))
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/metrics.rs
Expand Up @@ -104,6 +104,12 @@ impl Metrics {
}
}

impl Default for Metrics {
fn default() -> Self {
Self::new()
}
}

impl Debug for Metrics {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("Metrics")
Expand Down
2 changes: 1 addition & 1 deletion src/tiny_lfu.rs
Expand Up @@ -108,7 +108,7 @@ impl TinyLFU for TinyLFUCache {
} else {
self.sketcher.insert(k, 1);
self.previous_window.remove(k);
self.actual_window.insert(k.clone());
self.actual_window.insert(*k);
}
self.increments += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ttl.rs
Expand Up @@ -151,7 +151,7 @@ impl Expiration for ExpirationMap {
let mut result = HashSet::new();
let mut buckets = Vec::new();
for (id, _) in self.buckets.range(..now) {
buckets.push(id.clone())
buckets.push(*id)
}
for bucket in buckets {
for item in self.buckets.remove(&bucket).unwrap() {
Expand Down

0 comments on commit 4d431e1

Please sign in to comment.