Get alternative input file via env variable instead

This commit is contained in:
kageru 2021-12-01 23:12:39 +01:00
parent 731d7f5e33
commit b734f0c5af
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -1,13 +1,7 @@
use std::env;
pub fn read_file(day: usize) -> String {
std::fs::read_to_string(
env::args()
.nth(1)
.filter(|n| n != "--bench")
.unwrap_or_else(|| format!("inputs/day{:0>2}", day)),
)
.unwrap()
std::fs::read_to_string(env::var("AOC_INPUT").unwrap_or_else(|_| format!("inputs/day{:0>2}", day))).unwrap()
}
#[inline]