If I wanted to get the index of the first occurrence of, say, substring "foo" within a string "foo bar foo baz foo", I'd use:
fn main() {
let my_string = String::from("foo bar foo baz foo");
println!("{:?}", my_string.find("foo"));
}
...which would give me Some(0).
However, I need to find indexes of all occurrences of a substring within a string. In this scenario, I'd need something like:
[0, 8, 16]
How can I do this idiomatically in Rust?