2015: day01: finish
This commit is contained in:
parent
dd4e610324
commit
c420ed9e8b
7 changed files with 133 additions and 0 deletions
29
aoc2015/src/main.rs
Normal file
29
aoc2015/src/main.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use std::env;
|
||||
|
||||
use aoc2015::day01;
|
||||
|
||||
use aoc2015::Result;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let days: &[fn() -> Result<()>] = &[day01::run];
|
||||
|
||||
let mut args = env::args();
|
||||
args.next();
|
||||
|
||||
match args.next() {
|
||||
Some(arg) => {
|
||||
let day: usize = arg.parse().expect("Please provide a day number");
|
||||
days[day - 1]().expect("error running day specified");
|
||||
}
|
||||
None => {
|
||||
for (i, day) in days.iter().enumerate() {
|
||||
let i = i + 1;
|
||||
println!("day{}: ", i);
|
||||
day().unwrap_or_else(|e| panic!("error running day {}: {}", i, e));
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue