Fix Eq for Move so that it agrees with Ord, as required.
This commit is contained in:
parent
a85d69a36c
commit
7bf5bf22d4
@ -191,13 +191,21 @@ impl Board {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(Debug)]
|
||||||
struct Move {
|
struct Move {
|
||||||
from: Point2d,
|
from: Point2d,
|
||||||
dir: Vec2d,
|
dir: Vec2d,
|
||||||
prio: i32,
|
prio: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Move {
|
||||||
|
fn eq(&self, other: &Move) -> bool {
|
||||||
|
self.prio == other.prio
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for Move {}
|
||||||
|
|
||||||
impl PartialOrd for Move {
|
impl PartialOrd for Move {
|
||||||
fn partial_cmp(&self, other: &Move) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Move) -> Option<Ordering> {
|
||||||
self.prio.partial_cmp(&other.prio)
|
self.prio.partial_cmp(&other.prio)
|
||||||
|
@ -193,13 +193,21 @@ impl Board {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(Debug)]
|
||||||
struct Move {
|
struct Move {
|
||||||
from: Point2d,
|
from: Point2d,
|
||||||
dir: Vec2d,
|
dir: Vec2d,
|
||||||
prio: i32,
|
prio: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Move {
|
||||||
|
fn eq(&self, other: &Move) -> bool {
|
||||||
|
self.prio == other.prio
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for Move {}
|
||||||
|
|
||||||
impl PartialOrd for Move {
|
impl PartialOrd for Move {
|
||||||
fn partial_cmp(&self, other: &Move) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Move) -> Option<Ordering> {
|
||||||
self.prio.partial_cmp(&other.prio)
|
self.prio.partial_cmp(&other.prio)
|
||||||
|
Loading…
Reference in New Issue
Block a user