[−][src]Function line_span::find_next_line_range
pub fn find_next_line_range(text: &str, index: usize) -> Option<Range<usize>>
Find the start and 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
find_next_line_start
to find only the start of the next line.find_next_line_end
to find only the end of the next line.find_line_range
to find the start and end of the current line.find_prev_line_range
to find the start and end of the previous line.
Panics
Panics if index
is out of bounds.
Example
let text = "foo\nbar\nbaz"; let i = 1; // 'o' let range = line_span::find_next_line_range(text, i).unwrap(); assert_eq!(range, 4..7); let line = &text[range]; assert_eq!(line, "bar");