rust iterate over split

To iterate over a string split by a delimiter in Rust, you can use the split method provided by the str type. Here's an example:

fn main() {
    let my_string = "Hello, World!";
    let delimiter = ",";

    for word in my_string.split(delimiter) {
        println!("{}", word);
    }
}

In this example, the split method is called on the my_string variable, passing the delimiter as an argument. The method returns an iterator that yields each substring between the delimiters. The for loop then iterates over the substrings and prints them.

Please note that the split method splits the string into substrings based on the delimiter and does not include the delimiter itself. If you want to include the delimiter in the resulting substrings, you can use the split_terminator method instead.

I hope this helps! Let me know if you have any further questions.