card: rearrange

This commit is contained in:
2026-04-02 05:26:15 +01:00
committed by oreodave
parent 44d8e4eba0
commit 99bfd9ed37

View File

@@ -257,6 +257,24 @@ mod traits_numerics {
mod traits_ord {
use super::*;
use std::cmp::Ordering;
impl Ord for PlayingCard {
fn cmp(&self, other: &Self) -> Ordering {
self.abs().cmp(&other.abs())
}
}
impl Ord for Card {
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(Self::PlayingCard(c1), Self::PlayingCard(c2)) => c1.cmp(c2),
(Self::Joker(_), Self::Joker(_)) => Ordering::Equal,
(Self::Joker(_), _) => Ordering::Less,
(_, Self::Joker(_)) => Ordering::Greater,
}
}
}
impl PartialEq for PlayingCard {
fn eq(&self, other: &Self) -> bool {
self.cmp(other) == Ordering::Equal
@@ -280,23 +298,6 @@ mod traits_ord {
Some(self.cmp(other))
}
}
impl Ord for PlayingCard {
fn cmp(&self, other: &Self) -> Ordering {
self.abs().cmp(&other.abs())
}
}
impl Ord for Card {
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(Self::PlayingCard(c1), Self::PlayingCard(c2)) => c1.cmp(c2),
(Self::Joker(_), Self::Joker(_)) => Ordering::Equal,
(Self::Joker(_), _) => Ordering::Less,
(_, Self::Joker(_)) => Ordering::Greater,
}
}
}
}
mod traits_hash {