Macro starts_with
macro_rules! starts_with {
($haystack: expr, $pattern: expr) => { ... };
}
Available on crate feature
dep_const_str
only.Expand description
Returns true
if the given pattern matches a prefix of this string slice.
Returns false
if it does not.
The pattern type must be one of
ยงExamples
const BANANAS: &str = "bananas";
const A: bool = const_str::starts_with!(BANANAS, "bana");
const B: bool = const_str::starts_with!(BANANAS, "nana");
const C: bool = const_str::starts_with!(BANANAS, 'b');
assert_eq!([A, B, C], [true, false, true]);