Rust Split a string


Example

let strings = "bananas,apples,pear".split(",");

split returns an iterator.

for s in strings {
  println!("{}", s)
}

And can be "collected" in a Vec with the Iterator::collect method.

let strings: Vec<&str> = "bananas,apples,pear".split(",").collect(); // ["bananas", "apples", "pear"]