Skip to main content

find_tail_offset

Function find_tail_offset 

Source
pub fn find_tail_offset(src: &dyn Source, n: usize) -> usize
Expand description

Find the byte offset such that bytes[offset..] is exactly the last n logical lines of src (lines delimited by \n; a trailing \n at EOF is not its own line). Returns 0 when the source has fewer than n lines, or src.len() when n == 0.

Reverse-scans in 64 KiB chunks so a 10 GB file stays cheap — only the trailing pages need to be touched.