test: boost coverage to 76% and optimize Store inspection
This commit is contained in:
1 parent
81aac7245b
commit
26cf6cee80
3 files changed
+340
-1
No files matched your search
@@ -45,6 +45,14 @@ impl<T: DeserializeOwned + Default + Serialize + Clone + Send + 'static> Store<T
|
||||
lock.clone()
|
||||
}
|
||||
|
||||
pub fn inspect<F, R>(&self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&T) -> R,
|
||||
{
|
||||
let lock = self.cache.read().unwrap();
|
||||
f(&lock)
|
||||
}
|
||||
|
||||
pub fn modify<F: FnOnce(&mut T)>(&self, f: F) {
|
||||
let mut lock = self.cache.write().unwrap();
|
||||
f(&mut lock);
|
||||
|
||||
Reference in new issue
Block a user