From 881d42dccbc8967ae0b328ce44d1b529a8d49221 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9gory=20Burri?= Date: Thu, 16 Jul 2020 11:50:47 +0200 Subject: [PATCH] Update dependencies and readme --- Cargo.toml | 8 ++++---- README.md | 24 ++++++++++++++++++++++++ src/main.rs | 11 ++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 40784cc..292bbbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -itertools = "0.8" -threadpool = "1.7" +itertools = "0.9" +threadpool = "1.8" regex = "1" -num = "0.2" -num_enum = "0.4" \ No newline at end of file +num = "0.3" +num_enum = "0.5" \ No newline at end of file diff --git a/README.md b/README.md index d438ab1..f6047d0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,27 @@ # AdventOfCode2019 https://adventofcode.com/2019 + + +# Running tests + +Example for day 1 tests: + +~~~ +cargo test day01 -- --nocapture +~~~ + +All tests: + +~~~ +cargo test -- --nocapture +~~~ + + +# Running a day code + +~~~ +cargo run -- n +~~~ + +Where 'n' is a number from 1 to 25 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8c2f600..f249fb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -197,9 +197,14 @@ fn main() { println!("Time to execute all days: {}", format_micros(now.elapsed().as_micros())); } else { for arg in args { - let day = arg.parse::().unwrap(); - if day > days.len() { panic!("Unknown day: {}", day) } - do_day(&days, day) + match arg.parse::() { + Ok(day) if day >= 1 && day <= days.len() => + do_day(&days, day), + Ok(day) => + println!("Unknown day: {}", day), + Err(error) => + println!("Unable to parse day number: \"{}\", error: {}", arg, error) + } } } } -- 2.45.2