[−][src]Function line_span::find_line_end
pub fn find_line_end(text: &str, index: usize) -> usize
Find the end (byte index) of the line, which index
is within.
Note the end is the last character, excluding \n
and \r\n
.
See also
find_line_range
to find both start and end of a line.find_line_start
to find the start of the line.find_next_line_end
to find the end of the next line.find_prev_line_end
to find the end of the previous line.
Panics
Panics if index
is out of bounds.
Example
let text = "foo\nbar\nbaz"; let i = 5; // 'a' let end = line_span::find_line_end(text, i); assert_eq!(end, 7); assert_eq!(&text[..end], "foo\nbar");