Function ropey::str_utils::line_to_byte_idx

source ยท
pub fn line_to_byte_idx(text: &str, line_idx: usize) -> usize
Expand description

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

Returns the byte index of the start of the specified line. Line 0 is the start of the string, and subsequent lines start immediately after each line break character.

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

Runs in O(N) time.