Function std::sys_common::memchr::memrchr

source ·
pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize>
Expand description

A safe interface to memrchr.

Returns the index corresponding to the last occurrence of needle in haystack, or None if one is not found.


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

use memchr::memrchr;

let haystack = b"the quick brown fox";
assert_eq!(memrchr(b'o', haystack), Some(17));