From 3f9f7afd2795718781f964063a9b5030f0defa27 Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Mon, 8 Dec 2025 13:32:46 -0800 Subject: [PATCH] day8: avoid having to manually define all the cmp traits --- src/day8.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/day8.rs b/src/day8.rs index f4ed5a6..0f8c360 100644 --- a/src/day8.rs +++ b/src/day8.rs @@ -138,28 +138,12 @@ fn part2(input: &Circuits) -> u64 { panic!() } +#[derive(PartialEq, Eq, PartialOrd, Ord)] struct JunctionPair { + d: u64, a: usize, b: usize, - d: u64, } -impl Eq for JunctionPair {} -impl PartialEq for JunctionPair { - fn eq(&self, other: &Self) -> bool { - self.d == other.d - } -} -impl PartialOrd for JunctionPair { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.d.cmp(&other.d)) - } -} -impl Ord for JunctionPair { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.d.cmp(&other.d) - } -} - fn make_heap(circuits: &Circuits) -> BinaryHeap> { BinaryHeap::from_iter( circuits