1 | pub(crate) fn memchr(n1: u8, haystack: &[u8]) -> Option<usize> { |
2 | haystack.iter().position(|&b| b == n1) |
3 | } |
4 | |
5 | pub(crate) fn memchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option<usize> { |
6 | haystack.iter().position(|&b| b == n1 || b == n2) |
7 | } |
8 | |
9 | pub(crate) fn memchr3( |
10 | n1: u8, |
11 | n2: u8, |
12 | n3: u8, |
13 | haystack: &[u8], |
14 | ) -> Option<usize> { |
15 | haystack.iter().position(|&b| b == n1 || b == n2 || b == n3) |
16 | } |
17 | |
18 | pub(crate) fn memrchr(n1: u8, haystack: &[u8]) -> Option<usize> { |
19 | haystack.iter().rposition(|&b| b == n1) |
20 | } |
21 | |
22 | pub(crate) fn memrchr2(n1: u8, n2: u8, haystack: &[u8]) -> Option<usize> { |
23 | haystack.iter().rposition(|&b| b == n1 || b == n2) |
24 | } |
25 | |
26 | pub(crate) fn memrchr3( |
27 | n1: u8, |
28 | n2: u8, |
29 | n3: u8, |
30 | haystack: &[u8], |
31 | ) -> Option<usize> { |
32 | haystack.iter().rposition(|&b| b == n1 || b == n2 || b == n3) |
33 | } |
34 | |