From 283e02d782167ef5961b4acb1f8c6647e9ae7357 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 9 Apr 2026 19:18:00 +0100 Subject: [PATCH] card:impls: Card::{is_joker,playing_card,rank,suit} --- src/card/impls.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/card/impls.rs b/src/card/impls.rs index d155fd9..257b4d6 100644 --- a/src/card/impls.rs +++ b/src/card/impls.rs @@ -64,6 +64,25 @@ impl Card { Self::PlayingCard(PlayingCard::new(deck, rank, suit)) } + pub fn is_joker(&self) -> bool { + matches!(self, Card::Joker(_)) + } + + fn playing_card(&self) -> Option { + match self { + Card::Joker(_) => None, + Card::PlayingCard(pc) => Some(*pc), + } + } + + pub fn rank(&self) -> Option { + self.playing_card().and_then(|pc| Some(pc.rank)) + } + + pub fn suit(&self) -> Option { + self.playing_card().and_then(|pc| Some(pc.suit)) + } + pub fn deck_abs(&self) -> i64 { match *self { Self::Joker(x) => x,