Sorry to jump in here, I was just confused about something:
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum HandValue {
HighCard(Rank),
Pair(Rank),
TwoPair {
high_card: Rank,
other: Rank,
},
ThreeOfAKind(Rank),
Straight {
highest_value: Rank,
},
Flush {
high_card: Rank,
other_cards: [Rank; 4],
},
FullHouse {
triple: Rank,
pair: Rank,
},
FourOfAKind(Rank),
StraightFlush {
highest_rank: Rank,
other_cards: [Rank; 4],
},
}
For Flush
and StraightFlush
, why do you separate highest_rank
from other_cards
? Is it just a convenience?
And separately (or maybe not), will the derivation of Ord
Do The Right Thing when highest_value
are the same? I.E., will "QS 9S 7S 3S 2S" "QS 9S 7S 4S 3S" be considered greater than "QD 9D 7D 3D 1D" "QD 9D 7D 4D 2D" automatically? And if so, why not just have a single 5-length Rank
array?
Note: edited to fix my sample poker hands because I forgot that aces are high in poker