1
0
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:
Chayim Refael Friedman 2023-10-23 23:36:26 +03:00 committed by GitHub
parent ecd2bc863e
commit 3ba21370bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,6 @@ fn main() {
}
fn count_chars(s: &str) -> usize {
s.chars().map(|_| 1).sum()
s.chars().count()
}
```