modes:pair: adjust Ord impl for Pair
Instead of doing a deep-check where we compare their best member before their worst member, we just compare by the best member. This allows (Joker, 4S) to be equal to (4C, 4S).
This commit is contained in:
@@ -50,12 +50,8 @@ use std::cmp::Ordering;
|
|||||||
|
|
||||||
impl Ord for Pair {
|
impl Ord for Pair {
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
match (self.0.cmp(&other.0), self.1.cmp(&other.1)) {
|
// We order pairs by their "best" member i.e. Pair::1
|
||||||
// If Pair::1 are equal, then it's dependent on Pair::0
|
self.1.cmp(&other.1)
|
||||||
(x, Ordering::Equal) => x,
|
|
||||||
// Otherwise leave it to Pair::1
|
|
||||||
(_, x) => x,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user