1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::{
    fs::File,
    io::{BufReader, Result},
    path::Path,
};

/// Create a `File` `BufReader` from a `Path`. Otherwise throw IO Error.
pub fn read_file<P>(path: P) -> Result<BufReader<File>>
where
    P: AsRef<Path>,
{
    let file = File::open(path)?;
    Ok(BufReader::new(file))
}