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

This commit is contained in:
Juergen Stuber 2018-12-03 20:36:50 +01:00
parent a85d69a36c
commit 7bf5bf22d4
2 changed files with 18 additions and 2 deletions

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)

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)