From e8f5d7620ff530a4c088dc757af21f4371040af1 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 25 Apr 2023 10:41:05 +0200 Subject: [PATCH] fix: Fix status command panicking when additional LRU caches are set up --- crates/ide/src/status.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index 0597302ca8..3dfbc1874b 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs @@ -227,9 +227,10 @@ impl fmt::Display for SymbolsStats { } impl StatCollect> for SymbolsStats { fn collect_entry(&mut self, _: Key, value: Option>) { - let symbols = value.unwrap(); - self.total += symbols.len(); - self.size += symbols.memory_size(); + if let Some(symbols) = value { + self.total += symbols.len(); + self.size += symbols.memory_size(); + } } } @@ -254,8 +255,7 @@ impl fmt::Display for AttrsStats { impl StatCollect for AttrsStats { fn collect_entry(&mut self, _: Key, value: Option) { - let attrs = value.unwrap(); self.entries += 1; - self.total += attrs.len(); + self.total += value.map_or(0, |it| it.len()); } }