Iterating on Strings
We'll cover the following...
String
s and string slices behave a bit strangely with iteration as well. Let’s have a look at why:
Press + to interact
fn main() {let name = "Michael";for x in name {println!("{}", x);}}
This results in the error message:
error[E0277]: `&str` is not an iterator
--> src/main.rs:4:14
|
4 | for
...