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