memchr, but searches for any of three bytes instead of just one.
This returns the index corresponding to the first occurrence of
the first occurrence of
needle2, or the first occurence of
haystack (whichever occurs earliest), or
None if none are found.
While this is operationally the same as something like
haystack.iter().position(|&b| b == needle1 || b == needle2 || b == needle3),
memchr3 will use a highly optimized routine that can be
up to an order of magnitude faster in some cases.
This shows how to find the first position of any of three bytes in a byte string.
use memchr::memchr3; let haystack = b"the quick brown fox"; assert_eq!(memchr3(b'k', b'q', b'e', haystack), Some(2));