refac(rust): use hashmap entry for in-place manipulation
This commit is contained in:
parent
2adc74168d
commit
7c6d9ae21d
1 changed files with 1 additions and 1 deletions
|
@ -4,7 +4,7 @@ fn count_duplicates(text: &str) -> u32 {
|
||||||
text.to_lowercase()
|
text.to_lowercase()
|
||||||
.chars()
|
.chars()
|
||||||
.fold(HashMap::<char, u32>::new(), |mut hm, c| {
|
.fold(HashMap::<char, u32>::new(), |mut hm, c| {
|
||||||
hm.insert(c, hm.get(&c).copied().unwrap_or_default() + 1);
|
(*hm.entry(c).or_default()) += 1;
|
||||||
hm
|
hm
|
||||||
})
|
})
|
||||||
.values()
|
.values()
|
||||||
|
|
Loading…
Reference in a new issue