str_indices::chars

Function to_byte_idx

Source
pub fn to_byte_idx(text: &str, char_idx: usize) -> usize
Expand description

Converts from char-index to byte-index in a string slice.

Any past-the-end index will return the one-past-the-end byte index.

Runs in O(N) time.