diff --git a/rust/tests/2_counting_duplicates.rs b/rust/tests/2_counting_duplicates.rs index 7dfa766..c36637e 100644 --- a/rust/tests/2_counting_duplicates.rs +++ b/rust/tests/2_counting_duplicates.rs @@ -4,7 +4,7 @@ fn count_duplicates(text: &str) -> u32 { text.to_lowercase() .chars() .fold(HashMap::::new(), |mut hm, c| { - hm.insert(c, hm.get(&c).copied().unwrap_or_default() + 1); + (*hm.entry(c).or_default()) += 1; hm }) .values()