Initial commit.

This commit is contained in:
2023-12-02 00:39:37 +01:00
commit 2524727f26
7 changed files with 1131 additions and 0 deletions

16
src/input/mod.rs Normal file
View File

@@ -0,0 +1,16 @@
use std::{path::Path, io::{BufReader, BufRead, self}, fs::File};
#[derive(Debug)]
pub struct AdventError(String);
impl From<io::Error> for AdventError {
fn from(e: io::Error) -> Self {
AdventError(e.to_string())
}
}
pub fn read_into_vec(path: &Path) -> Result<Vec<String>, AdventError> {
let file = File::open(path).expect("no such file");
let buf = BufReader::new(file);
buf.lines().map(|line| line.map_err(Into::into)).collect::<Result<Vec<String>, AdventError>>()
}