Function konst::slice::bytes_find

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

Finds the byte offset of pattern in left.

Returns None if pattern isn’t inside left

§Example

use konst::slice::bytes_find;

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