konst::slice

Function bytes_end_with

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

Whether pattern is the end of left.

A const analog of <[u8]>::ends_with

ยงExample

use konst::slice::bytes_end_with;

assert!( bytes_end_with(b"foo,bar,baz", b",baz"));
assert!( bytes_end_with(b"foo,bar,baz", "bar,baz"));
assert!( bytes_end_with(b"foo,bar,baz", &'z'));

assert!(!bytes_end_with(b"foo,bar,baz", b"bar"));
assert!(!bytes_end_with(b"foo,bar,baz", b"foo"));