simplyfy the reading function

This commit is contained in:
Leo Drachenfeuer 2022-12-08 02:53:21 +01:00
parent 225b3acb74
commit 453141fe39
Signed by: dragonleo
GPG key ID: A8338FC081137CF0

View file

@ -1,11 +1,11 @@
use std::fs::File; use std::fs::File;
use std::io::{self, BufRead}; use std::io::{Result, BufRead, BufReader,Lines};
use std::path::Path; use std::path::Path;
pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> pub fn read_lines<P>(filename: P) -> Result<Lines<BufReader<File>>>
where where
P: AsRef<Path>, P: AsRef<Path>,
{ {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(BufReader::new(file).lines())
} }