From 99bfd9ed3704193b12f965fa9440dad704640f70 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 2 Apr 2026 05:26:15 +0100 Subject: [PATCH] card: rearrange --- src/card.rs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/card.rs b/src/card.rs index 690c831..ae27de1 100644 --- a/src/card.rs +++ b/src/card.rs @@ -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 {