Function konst::slice::bytes_start_with

source ·
pub const fn bytes_start_with<const N: usize, P>(
    left: &[u8],
    pattern: &P
) -> bool
where P: ?Sized + BytesPattern<N>,
Expand description

Whether pattern is the start of left.

This is analogous to <[u8]>::starts_with

§Example

use konst::slice::bytes_start_with;

assert!( bytes_start_with(b"foo,bar,baz", "foo,"));
assert!( bytes_start_with(b"foo,bar,baz", &'f'));
assert!( bytes_start_with(b"foo,bar,baz", &[b'f', b'o', b'o']));
assert!(!bytes_start_with(b"foo,bar,baz", "bar"));
assert!(!bytes_start_with(b"foo,bar,baz", "baz"));