Added day 4
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::{io::{BufReader, BufRead, self}, fs::File, str::FromStr, path::Path, convert::Infallible, num::ParseIntError};
|
||||
use std::{io::{BufReader, BufRead, self}, fs::File, str::FromStr, path::Path, convert::Infallible, num::{ParseIntError, TryFromIntError}};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AdventError(pub String);
|
||||
@@ -21,6 +21,12 @@ impl From<Infallible> for AdventError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TryFromIntError> for AdventError {
|
||||
fn from(e: TryFromIntError) -> Self {
|
||||
AdventError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_into_vec<T:FromStr>(file_path : &Path) -> Result<Vec<T>, AdventError> where AdventError: From<<T as FromStr>::Err> {
|
||||
let file = File::open(file_path).expect("no such file");
|
||||
let buf = BufReader::new(file);
|
||||
|
||||
Reference in New Issue
Block a user