Macro split_ascii_whitespace
macro_rules! split_ascii_whitespace {
($s: expr) => { ... };
}
Expand description
Returns an array of substrings of a string slice, separated by ASCII whitespace.
ASCII whitespace characters are: space (
), tab (\t
), newline (\n
),
carriage return (\r
), and form feed (\f
).
Consecutive whitespace characters are treated as a single separator. Leading and trailing whitespace is ignored.
This macro is const-context only.
See also str::split_ascii_whitespace
.
§Examples
const TEXT: &str = " hello world ";
const WORDS_ARRAY: [&str; 2] = const_str::split_ascii_whitespace!(TEXT);
const WORDS_SLICE: &[&str] = &const_str::split_ascii_whitespace!(TEXT);
assert_eq!(WORDS_ARRAY, WORDS_SLICE);
assert_eq!(WORDS_SLICE, &["hello", "world"]);
const TEXT: &str = "word1\t\tword2\n\nword3";
const WORDS: &[&str] = &const_str::split_ascii_whitespace!(TEXT);
assert_eq!(WORDS, &["word1", "word2", "word3"]);