macro_rules! str_split_pat {
($string:expr, $splitter:expr $(,)?) => { ... };
}
Expand description
Version of str_split
which evaluates to a &'static [&'static str]
.
ยงExample
Using the currently unstable inline_const_pat
feature to use this macro in patterns:
#![feature(inline_const_pat)]
use const_format::str_split_pat;
assert!(is_it(&["foo", "bar", "baz"]));
assert!(!is_it(&["foo", "bar"]));
fn is_it(slice: &[&str]) -> bool {
const SEP: char = ' ';
matches!(slice, str_split_pat!("foo bar baz", SEP))
}