pub const fn bytes_strip_prefix<'a, const N: usize, P>(
left: &'a [u8],
prefix: &P,
) -> Option<&'a [u8]>where
P: ?Sized + BytesPattern<N>,
Expand description
Remove prefix
from the start of left
.
Returns None
if prefix
is not the start of left
.
This is analogous to
<[u8]>::strip_prefix
ยงExample
use konst::slice::bytes_strip_prefix;
assert_eq!(bytes_strip_prefix(b"foo,bar,baz", b"foo,"), Some("bar,baz".as_bytes()));
assert_eq!(bytes_strip_prefix(b"foo,bar,baz", "foo,bar,"), Some("baz".as_bytes()));
assert_eq!(bytes_strip_prefix(b"foo,bar,baz", &'f'), Some("oo,bar,baz".as_bytes()));
assert_eq!(bytes_strip_prefix(b"foo,bar,baz", b"bar"), None);
assert_eq!(bytes_strip_prefix(b"foo,bar,baz", b"baz"), None);