Chars and Bytes
Strings are UTF-8. chars() iterates characters and len counts bytes.
Example
fn main() {
let s = "héllo";
println!("{} {}", s.len(), s.chars().count());
for c in "hé".chars() { print!("{} ", c); }
println!();
}Result
6 5 h é
Exercise
Count characters.
s.chars().()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.