str_utils/
starts_with_multiple.rs1pub trait StartsWithMultiple {
3 fn starts_with_multiple<S: AsRef<[u8]>>(&self, bs: &[S]) -> Option<usize>;
5}
6
7impl StartsWithMultiple for [u8] {
8 #[inline]
9 fn starts_with_multiple<S: AsRef<[u8]>>(&self, bs: &[S]) -> Option<usize> {
10 let a = self;
11
12 bs.iter().position(|b| a.starts_with(b.as_ref()))
13 }
14}
15
16impl StartsWithMultiple for str {
17 #[inline]
18 fn starts_with_multiple<S: AsRef<[u8]>>(&self, bs: &[S]) -> Option<usize> {
19 self.as_bytes().starts_with_multiple(bs)
20 }
21}