Macro split
macro_rules! split {
($s: expr, $pat: expr) => { ... };
}
Available on crate feature
dep_const_str
only.Expand description
Returns an array of substrings of a string slice, separated by characters matched by a pattern.
See str::split
.
The pattern type must be one of
ยงExamples
const SEPARATOR: &str = ", ";
const TEXT: &str = "lion, tiger, leopard";
const ANIMALS_ARRAY: [&str;3] = const_str::split!(TEXT, SEPARATOR);
const ANIMALS_SLICE: &[&str] = &const_str::split!(TEXT, SEPARATOR);
assert_eq!(ANIMALS_ARRAY, ANIMALS_SLICE);
assert_eq!(ANIMALS_SLICE, &["lion", "tiger", "leopard"]);