Skip to content

Commit

Permalink
Merge pull request #194 from moka-rs/fix-clippy-warnings-1.66
Browse files Browse the repository at this point in the history
Fix Clippy warnings (Rust 1.66 beta)
  • Loading branch information
tatsuya6502 authored Nov 2, 2022
2 parents ee57915 + 5f716a8 commit 0976f84
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/cht/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,10 @@ mod tests {
.collect::<Result<BTreeMap<_, _>, _>>()
.expect("Got an error from a thread");

assert_eq!(hashmap.len(), MAX_VALUE as usize);
assert_eq!(hashmap.len(), MAX_VALUE);

// Verify that the sum of success insertion counts should be MAX_VALUE.
let sum_of_insertions: usize = results1
.iter()
.map(|(_thread_id, success_count)| success_count)
.sum();
let sum_of_insertions: usize = results1.values().sum();
assert_eq!(sum_of_insertions, MAX_VALUE);

// Get all entries from the cht HashMap and turn them into the same format
Expand Down
2 changes: 1 addition & 1 deletion src/dash/base_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ where
dashmap::DashMap::with_capacity_and_hasher(initial_capacity, build_hasher.clone());

Self {
max_capacity: max_capacity.map(|n| n as u64),
max_capacity,
entry_count: Default::default(),
weighted_size: Default::default(),
cache,
Expand Down
2 changes: 1 addition & 1 deletion src/sync_base/base_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ where

Self {
name,
max_capacity: max_capacity.map(|n| n as u64),
max_capacity,
entry_count: Default::default(),
weighted_size: Default::default(),
cache,
Expand Down
6 changes: 3 additions & 3 deletions src/unsync/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ where
);

Self {
max_capacity: max_capacity.map(|n| n as u64),
max_capacity,
entry_count: 0,
weighted_size: 0,
cache,
Expand Down Expand Up @@ -620,12 +620,12 @@ where

fn saturating_add_to_total_weight(&mut self, weight: u64) {
let total = &mut self.weighted_size;
*total = total.saturating_add(weight as u64);
*total = total.saturating_add(weight);
}

fn saturating_sub_from_total_weight(&mut self, weight: u64) {
let total = &mut self.weighted_size;
*total = total.saturating_sub(weight as u64);
*total = total.saturating_sub(weight);
}

#[inline]
Expand Down

0 comments on commit 0976f84

Please sign in to comment.