From 5016e4c01a58bd14070cd918cd88339f0ed9759c Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Mon, 30 Sep 2024 17:46:09 -0400 Subject: [PATCH] fmt --- crates/katana/primitives/src/trace.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/katana/primitives/src/trace.rs b/crates/katana/primitives/src/trace.rs index 26ddee3b99..8a69871ed3 100644 --- a/crates/katana/primitives/src/trace.rs +++ b/crates/katana/primitives/src/trace.rs @@ -185,7 +185,28 @@ impl BuiltinCounters { impl From> for BuiltinCounters { fn from(map: HashMap) -> Self { // Filter out the builtins with 0 count. - let filtered = map.into_iter().filter(|builtin| builtin.1 != 0).collect(); + let filtered = map.into_iter().filter(|(_, count)| *count != 0).collect(); BuiltinCounters(filtered) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_builtin_counters_from_hashmap_removes_zero_entries() { + let mut map = HashMap::new(); + map.insert(BuiltinName::output, 1); + map.insert(BuiltinName::range_check, 0); + map.insert(BuiltinName::pedersen, 2); + map.insert(BuiltinName::ecdsa, 0); + + let counters = BuiltinCounters::from(map); + + assert_eq!(counters.output(), Some(1)); + assert_eq!(counters.range_check(), None); + assert_eq!(counters.pedersen(), Some(2)); + assert_eq!(counters.ecdsa(), None); + } +}