Here we use range to sum the numbers in a slice. Arrays work like this too.
To run the program, put the code in main.rs and use cargo run if you’re using Cargo as your build system.
In Rust, for loops iterate over iterators, which is a common pattern to iterate over the elements of various collections. Here, enumerate is used to get the index along with the item, and chars() is used to iterate over each character in a string.