From 7bf5bf22d49d3f457f8ebeb733d79d87d00bd215 Mon Sep 17 00:00:00 2001 From: Juergen Stuber Date: Mon, 3 Dec 2018 20:36:50 +0100 Subject: [PATCH] Fix Eq for Move so that it agrees with Ord, as required. --- src/bin/dualmaze/main.rs | 10 +++++++++- src/bin/maze/main.rs | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/bin/dualmaze/main.rs b/src/bin/dualmaze/main.rs index 1f82539..37f7a22 100644 --- a/src/bin/dualmaze/main.rs +++ b/src/bin/dualmaze/main.rs @@ -191,13 +191,21 @@ impl Board { } } -#[derive(PartialEq, Eq)] +#[derive(Debug)] struct Move { from: Point2d, dir: Vec2d, prio: i32, } +impl PartialEq for Move { + fn eq(&self, other: &Move) -> bool { + self.prio == other.prio + } +} + +impl Eq for Move {} + impl PartialOrd for Move { fn partial_cmp(&self, other: &Move) -> Option { self.prio.partial_cmp(&other.prio) diff --git a/src/bin/maze/main.rs b/src/bin/maze/main.rs index b983a21..979cd69 100644 --- a/src/bin/maze/main.rs +++ b/src/bin/maze/main.rs @@ -193,13 +193,21 @@ impl Board { } } -#[derive(PartialEq, Eq)] +#[derive(Debug)] struct Move { from: Point2d, dir: Vec2d, prio: i32, } +impl PartialEq for Move { + fn eq(&self, other: &Move) -> bool { + self.prio == other.prio + } +} + +impl Eq for Move {} + impl PartialOrd for Move { fn partial_cmp(&self, other: &Move) -> Option { self.prio.partial_cmp(&other.prio)