std-method

str::split_ascii_whitespace

Split on ASCII whitespace, unlike split_whitespace which recognizes Unicode whitespace. Expected stdout (not executed): 2 3 Common mistake: Assuming a nonbreaking space is ASCII whitespace.

Formal Syntax & Structure

rust syntaxrust
fn split_ascii_whitespace(&self) -> SplitAsciiWhitespace<'_>

Working Example

Example Snippetrust
fn main() {    let s = "a\u{00A0}b c";    println!("{} {}", s.split_ascii_whitespace().count(), s.split_whitespace().count());}
Rust Reference