Browse Source

Fix Eq for Move so that it agrees with Ord, as required.

master
Juergen Stuber 2 years ago
parent
commit
7bf5bf22d4
2 changed files with 18 additions and 2 deletions
  1. +9
    -1
      src/bin/dualmaze/main.rs
  2. +9
    -1
      src/bin/maze/main.rs

+ 9
- 1
src/bin/dualmaze/main.rs View File

@ -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<Ordering> {
self.prio.partial_cmp(&other.prio)


+ 9
- 1
src/bin/maze/main.rs View File

@ -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<Ordering> {
self.prio.partial_cmp(&other.prio)


Loading…
Cancel
Save