1
0
Fork 0

day(01): use color-eyre for catching errors

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-12-01 14:29:48 +01:00
parent 7fb03bf9b2
commit 6b1802886d
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -1,5 +1,6 @@
use aoc_2022::file_to_lines; use aoc_2022::file_to_lines;
use color_eyre::eyre::Result;
use tracing::*; use tracing::*;
use tracing_subscriber::EnvFilter; use tracing_subscriber::EnvFilter;
@ -35,7 +36,7 @@ fn parse_input(pathname: &str) -> Vec<i32> {
.collect() .collect()
} }
fn main() { fn main() -> Result<()> {
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env()) .with_env_filter(EnvFilter::from_default_env())
.with_target(false) .with_target(false)
@ -44,11 +45,14 @@ fn main() {
.without_time() .without_time()
.compact() .compact()
.init(); .init();
color_eyre::install()?;
let input = parse_input("inputs/day01.txt"); let input = parse_input("inputs/day01.txt");
info!("Part 1: {}", part_1(&input)); info!("Part 1: {}", part_1(&input));
info!("Part 2: {}", part_2(&input)); info!("Part 2: {}", part_2(&input));
Ok(())
} }
#[cfg(test)] #[cfg(test)]