mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-14 22:15:54 +02:00
Simpler character counting (#1419)
`str.chars().map(|_| 1).sum()` is just `str.chars().count()`.
This commit is contained in:
parent
ecd2bc863e
commit
3ba21370bb
@ -23,6 +23,6 @@ fn main() {
|
||||
}
|
||||
|
||||
fn count_chars(s: &str) -> usize {
|
||||
s.chars().map(|_| 1).sum()
|
||||
s.chars().count()
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user