Skip to main content

char_to_byte

Function char_to_byte 

Source
pub fn char_to_byte(s: &str, char_idx: usize) -> usize
Expand description

Converts a char-indexed position in s to its byte offset.

Returns s.len() if char_idx is past the end, making it safe to use directly with String::insert and String::remove.