Skip to main content

case_insensitive_prefix_byte_len

Function case_insensitive_prefix_byte_len 

Source
fn case_insensitive_prefix_byte_len(s: &str, prefix: &str) -> Option<usize>
Expand description

Byte length in s of a prefix that case-insensitively matches prefix (always plain ASCII lowercase), or None if s doesn’t start with it. Walks s’s own char boundaries rather than slicing by an offset computed against a separately-lowercased copy of s — a char’s lowercase mapping can change UTF-8 byte length (e.g. the Kelvin sign ‘K’ -> ‘k’) or even character count (e.g. Turkish ‘İ’ -> “i̇”), which would otherwise misalign the offset or land it off a char boundary and panic on slice.