card: PlayingCard::iter_all_deck

Given a deck number, create an iterator over all Playing Cards in that
deck.
This commit is contained in:
2026-04-03 02:16:24 +01:00
committed by oreodave
parent 8e6e11e5be
commit c61626f2d0

View File

@@ -75,6 +75,12 @@ impl PlayingCard {
let suit = self.suit as i64;
(rank * 4) + suit
}
pub fn iter_all_deck(deck: usize) -> impl Iterator<Item = Self> {
let deck = deck as i64;
((deck * 52)..((deck + 1) * 52))
.filter_map(|x| PlayingCard::try_from(x).ok())
}
}
impl Card {