Skip to content

Commit ec5168f

Browse files
committed
reserve to ret &mut self
1 parent 281410b commit ec5168f

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/cache/arc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ impl<K, V, S> ArcCache<K, V, S> {
122122
}
123123

124124
/// 扩展当前容量
125-
pub fn reserve(&mut self, additional: usize) {
125+
pub fn reserve(&mut self, additional: usize) -> &mut Self {
126126
self.cap += additional;
127127
self.main_lfu.reserve(additional);
128128
self.main_lru.reserve(additional);
129129
self.ghost_lfu.reserve(additional);
130130
self.ghost_lru.reserve(additional);
131+
self
131132
}
132133

133134
/// 遍历当前的所有值

src/cache/lfu.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@ impl<K, V, S> LfuCache<K, V, S> {
243243
}
244244

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

250251
/// 遍历当前的所有值

src/cache/lruk.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ impl<K, V, S> LruKCache<K, V, S> {
208208
}
209209

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

215216
/// 遍历当前的所有值

0 commit comments

Comments
 (0)