split_whitespace reads words separated by any amount of whitespace without keeping the separators.

Program

Play the program to choose raw text and collect its visible words.

split_whitespace_words.rs
fn main() {
    let raw = ;
    let words: Vec<&str> = raw.split_whitespace().collect();
    println!("{:?}", words);
}
fn main() {
    let raw = ;
    let words: Vec<&str> = raw.split_whitespace().collect();
    println!("{:?}", words);
}
fn main() {
    let raw = ;
    let words: Vec<&str> = raw.split_whitespace().collect();
    println!("{:?}", words);
}
split_whitespace `split_whitespace` treats spaces, tabs, and newlines as separators.
borrowing The collected `&str` values borrow slices from the original string.
empty input An empty or all-whitespace string produces an empty iterator.