Function konst::slice::bytes_rfind

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

Finds the byte offset of pattern inside left, searching in reverse.

Returns None if pattern isn’t inside left.

§Example

use konst::slice::bytes_rfind;

assert_eq!(bytes_rfind(b"foo-bar-baz", &'q'), None);
assert_eq!(bytes_rfind(b"foo-bar-baz", b"foo"), Some(0));
assert_eq!(bytes_rfind(b"foo-bar-baz", "bar"), Some(4));
assert_eq!(bytes_rfind(b"foo-bar-baz", b"baz"), Some(8));