Skip to main content

find_byte

Function find_byte 

Source
pub fn find_byte(needle: u8, hay: &[u8]) -> Option<usize>
Expand description

The index of the first needle in hay.

Identical to hay.iter().position(|&b| b == needle), eight bytes per step.

ยงExamples

use parse_net::scan::find_byte;

assert_eq!(find_byte(b';', b"text/html; charset=utf-8"), Some(9));
assert_eq!(find_byte(b',', b"gzip"), None);