# memchr::memrchr3 - Rust
API documentation for the Rust `memrchr3` fn in crate `memchr`.
Keywords: rust, rustlang, rust-lang, memrchr3

# Function memchr::memrchr3 [−] [src]

    pub fn memrchr3(
        needle1: u8,
        needle2: u8,
        needle3: u8,
        haystack: &[u8]
    ) -> Option<usize>

Like `memrchr`, but searches for any of three bytes instead of just one.

This returns the index corresponding to the last occurrence of `needle1`, the last occurrence of `needle2`, or the last occurrence of `needle3` in `haystack` (whichever occurs later), or `None` if none are found.

While this is operationally the same as something like `haystack.iter().rposition(|&b| b == needle1 || b == needle2 || b == needle3)`, `memrchr3` will use a highly optimized routine that can be up to an order of magnitude faster in some cases.

# Example

This shows how to find the last position of any of three bytes in a byte string.

    use memchr::memrchr3;

    let haystack = b"the quick brown fox";
    assert_eq!(memrchr3(b'k', b'q', b'e', haystack), Some(8));