Skip to main content

str_offset

Function str_offset 

Source
pub fn str_offset(source: &str, substr: &str) -> u32
Expand description

Return the byte offset of substr within source.

Uses pointer arithmetic when substr is a true sub-slice of source (i.e. arena-allocated names pointing into the same backing string). Falls back to a content search when the pointers differ — this handles tests and callers that pass a differently-allocated copy of the source.