Function konst::slice::bytes_trim_start_matches

source ·
pub const fn bytes_trim_start_matches<'a, const N: usize, P>(
    this: &'a [u8],
    needle: &P
) -> &'a [u8]
where P: ?Sized + BytesPattern<N>,
Expand description

Removes all instances of needle from the start of this.

§Example

use konst::slice;

const TRIMMED0: &[u8] = slice::bytes_trim_start_matches(b"#####huh###", b"##");
const TRIMMED1: &[u8] = slice::bytes_trim_start_matches(b"[][]nice[][]", "[][]");
const TRIMMED2: &[u8] = slice::bytes_trim_start_matches(b"(((woah", &'(');

assert_eq!(TRIMMED0, b"#huh###");
assert_eq!(TRIMMED1, b"nice[][]");
assert_eq!(TRIMMED2, b"woah");