Function onejoker::cards::card_parse::card_parse
source · pub fn card_parse(text: &str) -> impl Iterator<Item = Card> + '_
Expand description
wiki | Convert text to iterator of Cards
Simple state-machine parser for strings that contain cards in “As” form. We accept a few extras here above the standard: “Jk”, “Jb”, and “Jw” for the red, black, and white jokers, respectively; “10” for the ten as well as “T”, and “1” for low ace (should only be used for testing).
use onejoker::prelude::*;
let text = " [2h 3s Td Kc Jk 7c Ad]";
let cards: Vec<Card> = card_parse(text).collect();
assert_eq!(cards.len(), 7);
assert_eq!(cards[0], DEUCE_OF_HEARTS);
assert_eq!(cards[4], JOKER);
assert_eq!(cards[6], ACE_OF_DIAMONDS);