fix(core): remove unwrap/expect in non-test code
- cache/lru.rs: replace lock().unwrap() with if let Ok guard, consistent with other lock acquisitions in the same file - service/repo/core.rs: replace try_into().unwrap() with copy_from_slice which is infallible for fixed-size slices - service/auth/rsa.rs: replace 3 expect() calls with map_err() for ChaCha20Poly1305 key init and session key retrieval - config/mod.rs: replace GLOBAL_CONFIG.get().expect() with unwrap_or_else fallback to empty config
This commit is contained in:
Vendored
+14
-14
@@ -174,22 +174,22 @@ impl<K: Eq + Hash + Clone, V: Clone> LruTtlCache<K, V> {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut lru = self.lru.lock().unwrap();
|
||||
if let Ok(mut lru) = self.lru.lock() {
|
||||
if lru.len() >= self.capacity
|
||||
&& let Some(evicted_key) = lru.pop_back()
|
||||
{
|
||||
self.map.remove(&evicted_key);
|
||||
}
|
||||
|
||||
if lru.len() >= self.capacity
|
||||
&& let Some(evicted_key) = lru.pop_back()
|
||||
{
|
||||
self.map.remove(&evicted_key);
|
||||
self.map.insert(
|
||||
key.clone(),
|
||||
CacheEntry {
|
||||
value,
|
||||
expires_at: now + ttl,
|
||||
},
|
||||
);
|
||||
lru.push_front(key);
|
||||
}
|
||||
|
||||
self.map.insert(
|
||||
key.clone(),
|
||||
CacheEntry {
|
||||
value,
|
||||
expires_at: now + ttl,
|
||||
},
|
||||
);
|
||||
lru.push_front(key);
|
||||
}
|
||||
|
||||
pub fn remove(&self, key: &K) -> Option<V> {
|
||||
|
||||
Reference in New Issue
Block a user