card: make_decks yields an iterator instead of a vector

This commit is contained in:
2026-04-03 05:35:59 +01:00
committed by oreodave
parent 555c8e127b
commit 47bb6c171e

View File

@@ -131,11 +131,9 @@ pub fn all_same_rank(cards: &[PlayingCard]) -> bool {
Note that each deck gets two jokers - this is added to the overall vector. Note that each deck gets two jokers - this is added to the overall vector.
*/ */
pub fn make_decks(number_of_decks: usize) -> Vec<Card> { pub fn make_decks(number_of_decks: usize) -> impl Iterator<Item = Card> {
let number_of_decks: i64 = number_of_decks.try_into().unwrap(); let number_of_decks: i64 = number_of_decks.try_into().unwrap();
(-(number_of_decks * 2)..(52 * number_of_decks)) (-(number_of_decks * 2)..(52 * number_of_decks)).map(Card::from)
.map(Card::from)
.collect::<Vec<_>>()
} }
mod trait_display { mod trait_display {