Add aoc crate that reads file from input argument; use it in the day01 crate

This commit is contained in:
Eryn Wells 2022-12-19 19:26:10 +00:00
parent 545463c40c
commit 4710909b98
6 changed files with 34 additions and 7 deletions

7
2022/aoc/Cargo.lock generated Normal file
View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aoc"
version = "0.1.0"

8
2022/aoc/Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "aoc"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

8
2022/aoc/src/lib.rs Normal file
View file

@ -0,0 +1,8 @@
use std::{env, fs};
pub fn read_input_file_to_string() -> String {
let args: Vec<String> = env::args().collect();
let filename = args.get(1).expect("Missing filename argument");
fs::read_to_string(&filename).expect("Unable to read file")
}