Skip to content

Commit

Permalink
reserve to ret &mut self
Browse files Browse the repository at this point in the history
  • Loading branch information
tickbh committed Jun 17, 2024
1 parent 281410b commit ec5168f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cache/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ impl<K, V, S> ArcCache<K, V, S> {
}

/// 扩展当前容量
pub fn reserve(&mut self, additional: usize) {
pub fn reserve(&mut self, additional: usize) -> &mut Self {
self.cap += additional;
self.main_lfu.reserve(additional);
self.main_lru.reserve(additional);
self.ghost_lfu.reserve(additional);
self.ghost_lru.reserve(additional);
self
}

/// 遍历当前的所有值
Expand Down
3 changes: 2 additions & 1 deletion src/cache/lfu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ impl<K, V, S> LfuCache<K, V, S> {
}

/// 扩展当前容量
pub fn reserve(&mut self, additional: usize) {
pub fn reserve(&mut self, additional: usize) -> &mut Self {
self.cap += additional;
self
}

/// 遍历当前的所有值
Expand Down
3 changes: 2 additions & 1 deletion src/cache/lruk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ impl<K, V, S> LruKCache<K, V, S> {
}

/// 扩展当前容量
pub fn reserve(&mut self, additional: usize) {
pub fn reserve(&mut self, additional: usize) -> &mut Self {
self.cap += additional;
self
}

/// 遍历当前的所有值
Expand Down

0 comments on commit ec5168f

Please sign in to comment.