use std::fs::File;
use std::io::BufRead;
use std::path::Path;
pub(crate) fn read_single_line<P>(fname: P) -> Option<String>
where
P: AsRef<Path>
{
if let Ok(mut lines) = read_lines(fname.as_ref()) {
if let Some(Ok(l)) = lines.next() {
Some(l.trim_end().to_string())
} else {
None
}
} else {
None
}
}
pub(crate) fn read_lines<P>(
filename: P
) -> std::io::Result<std::io::Lines<std::io::BufReader<File>>>
where
P: AsRef<Path>
{
let file = std::fs::File::open(filename)?;
Ok(std::io::BufReader::new(file).lines())
}