(haystack: &[u8], needle: &[u8], max_count: Option<usize>)
| 985 | |
| 986 | #[inline] |
| 987 | fn count_substring(haystack: &[u8], needle: &[u8], max_count: Option<usize>) -> usize { |
| 988 | let substrings = haystack.find_iter(needle); |
| 989 | if let Some(max_count) = max_count { |
| 990 | core::cmp::min(substrings.take(max_count).count(), max_count) |
| 991 | } else { |
| 992 | substrings.count() |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | pub trait ByteOr: ToPrimitive { |
| 997 | fn byte_or(&self, vm: &VirtualMachine) -> PyResult<u8> { |
no test coverage detected