1#[inline]
5pub fn split_once_ws(content: &str, start: usize, end: usize) -> (&str, usize) {
6 let bytes = content.as_bytes();
7 if let Some(ws_pos) =
8 memchr::memchr3(b' ', b'\t', b'\r', &bytes[start..end]).map(|offset| start + offset)
9 {
10 let rest = &bytes[ws_pos..end];
11 (&content[start..ws_pos], ws_pos + (rest.len() - rest.trim_ascii_start().len()))
12 } else {
13 (&content[start..end], end)
14 }
15}
16
17#[inline]
19pub fn first_word(content: &str, start: usize, end: usize) -> Option<(&str, usize)> {
20 let bytes = &content.as_bytes()[start..end];
21 let start = start + (bytes.len() - bytes.trim_ascii_start().len());
22 let (word, content_start) = split_once_ws(content, start, end);
23 if word.is_empty() { None } else { Some((word, content_start)) }
24}