1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
extern crate cards;
use std::cmp::{Ord};
#[derive(Debug, PartialEq)]
#[derive(Eq, Hash)]
#[derive(PartialOrd, Ord)]
pub enum HandRankClass {
HighCard,
OnePair,
TwoPair,
ThreeOfAKind,
Straight,
Flush,
FullHouse,
FourOfAKind,
StraightFlush,
}
pub type CactusKevCard = u32;
pub type HandRank = u16;
pub const HAND_RANK_COUNT : u16 = 7462;
pub fn hand_rank_to_class(val: &HandRank) -> HandRankClass {
match *val {
0...1276 => HandRankClass::HighCard,
1277...4136 => HandRankClass::OnePair,
4137...4994 => HandRankClass::TwoPair,
4995...5852 => HandRankClass::ThreeOfAKind,
5853...5862 => HandRankClass::Straight,
5863...7139 => HandRankClass::Flush,
7140...7295 => HandRankClass::FullHouse,
7296...7451 => HandRankClass::FourOfAKind,
7452...7461 => HandRankClass::StraightFlush,
_ => panic!("Unexpected hand rank value! '{}'", *val)
}
}