Explain runtime invariants and avoid redundant unwraps

This commit is contained in:
Samuel Onoja committed 2026-10-22 01:28:03 +01:00
1 parent 34f2f07301
commit 1b51ba83b4
116 files changed
+1643 -515

No files matched your search

+9 -2
View File
@@ -136,7 +136,10 @@ impl TintCache {
.iter()
.position(|entry| std::ptr::eq(entry.source, source) && entry.colors == colors)
{
let entry = self.entries.remove(index).unwrap();
let entry = self
.entries
.remove(index)
.expect("the cache lookup identifies an existing icon entry");
let handle = entry.handle.clone();
self.entries.push_back(entry);
return handle;
@@ -147,7 +150,11 @@ impl TintCache {
if bytes <= TINT_CACHE_BYTES {
while self.entries.len() >= TINT_CACHE_ENTRIES || self.bytes + bytes > TINT_CACHE_BYTES
{
self.bytes -= self.entries.pop_front().unwrap().bytes;
self.bytes -= self
.entries
.pop_front()
.expect("cache eviction requires an entry while over budget")
.bytes;
}
self.bytes += bytes;
self.entries.push_back(TintedIcon {