[][src]Function line_span::find_next_line_end

pub fn find_next_line_end(text: &str, index: usize) -> Option<usize>

Find the end (byte index) of the next line, the line after the one which index is within.

Note the end is the last character, excluding \n and \r\n.

Returns None if there is no next line.

See also

Panics

Panics if index is out of bounds.

Example

let text = "foo\nbar\nbaz";
let i = 1; // 'o'

let end = line_span::find_next_line_end(text, i).unwrap();

assert_eq!(end, 7);
assert_eq!(&text[..end], "foo\nbar");