Skip to main content

read_first_lines

Function read_first_lines 

Source
fn read_first_lines(path: impl AsRef<Path>, n: usize) -> Result<Vec<String>>
Expand description

读取文件前 n 行(用于解析 -- mode: 等头部元信息,避免整文件读入内存)。 不足 n 行时返回实际读到的行;任一行读取失败则整体返回该错误。