Function line_start_byte

Source
pub fn line_start_byte(text: &str, line: usize) -> usize
Expand description

Returns the UTF-8 byte offset at which a zero-based logical line starts.

Line zero starts at byte zero. A line beyond the available newline separators maps to text.len(), including in an empty string.

§Examples

use ailloli_ui_editor::code::line_start_byte;

assert_eq!(line_start_byte("é\nnext", 1), 3);
assert_eq!(line_start_byte("one", 9), 3);