From fdd41c9cb563bbff8e3e79651ea8740313796e1a Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Thu, 23 Nov 2023 19:20:34 +0000 Subject: [PATCH] Template (#5) * Setup project structure * Swtich to telemetry for traces * Add stub test module --------- Co-authored-by: Simon Martin --- Cargo.toml | 2 +- day1/src/lib.rs | 8 ++++++++ template/src/lib.rs | 7 +++++++ utils/src/graph.rs | 10 +++++++--- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 73af855..c2ad355 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ anyhow = "1.0.66" # A dead simple ANSI terminal color painting library. yansi = "1.0.0-gamma" -itertools = "0.11.0" +itertools = "0.12.0" # An implementation of regular expressions for Rust. This implementation uses finite automata … regex = "1.7.0" # Pathfinding, flow, and graph algorithms diff --git a/day1/src/lib.rs b/day1/src/lib.rs index 61b37c4..45cb56f 100644 --- a/day1/src/lib.rs +++ b/day1/src/lib.rs @@ -31,3 +31,11 @@ impl TryFrom> for Solution { Ok(solution) } } + +#[cfg(test)] +mod test { + #[test] + fn stub() { + assert_eq!(1 + 1, 2); + } +} diff --git a/template/src/lib.rs b/template/src/lib.rs index 61b37c4..0f04e01 100644 --- a/template/src/lib.rs +++ b/template/src/lib.rs @@ -31,3 +31,10 @@ impl TryFrom> for Solution { Ok(solution) } } +#[cfg(test)] +mod test { + #[test] + fn stub() { + assert_eq!(1 + 1, 2); + } +} diff --git a/utils/src/graph.rs b/utils/src/graph.rs index 8689b31..4206465 100644 --- a/utils/src/graph.rs +++ b/utils/src/graph.rs @@ -1,8 +1,10 @@ -use std::cmp::Eq; +use std::cmp::{Eq, PartialOrd}; use std::collections::{HashMap, HashSet, VecDeque}; use std::fmt::Debug; use std::hash::Hash; +use std::iter::Iterator; use std::marker::Copy; +use std::ops::Add; use tracing::debug; fn breadth_first_search_build_path<'a, N>( @@ -71,6 +73,8 @@ where None } +use tracing::debug; + pub fn dijkstra( nodes: &Vec, initial_score: IS, @@ -82,8 +86,8 @@ where GN: Fn(&N) -> NEIGH, IE: Fn(&N) -> bool, N: Debug + Eq + Copy + Hash, - R: Debug + std::cmp::PartialOrd + Copy + std::ops::Add + HasOne, - NEIGH: std::iter::Iterator, + R: Debug + PartialOrd + Copy + Add + HasOne, + NEIGH: Iterator, { let mut scores = HashMap::new(); for node in nodes {