padmet/
io.rs

1
2use std::fs::File;
3use std::io::{self, BufRead};
4use std::path::Path;
5
6// The output is wrapped in a Result to allow matching on errors.
7// Returns an Iterator to the Reader of the lines of the file.
8pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
9where
10    P: AsRef<Path>,
11{
12    let file = File::open(filename)?;
13    Ok(io::BufReader::new(file).lines())
14}