Function konst::slice::bytes_trim_end_matches

source ·
pub const fn bytes_trim_end_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 end of this.

§Example

use konst::slice;

const TRIMMED0: &[u8] = slice::bytes_trim_end_matches(b"oowowooooo", b"oo");
const TRIMMED1: &[u8] = slice::bytes_trim_end_matches(b"gooooo", "oo");
const TRIMMED2: &[u8] = slice::bytes_trim_end_matches(b"yesssssss", &'s');

assert_eq!(TRIMMED0, b"oowowo");
assert_eq!(TRIMMED1, b"go");
assert_eq!(TRIMMED2, b"ye");