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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
extern crate rand;
#[macro_export]
macro_rules! card {
($s:expr) => {
{
let cr = $crate::Card::from_str($s);
if cr.is_err() {
panic!("Not a known card {}", $s);
}
cr.unwrap()
}
};
}
#[macro_export]
macro_rules! hand {
() => {
Hand::new()
};
( $( $s:expr ),* ) => {
{
let mut hand = $crate::Hand::new();
$(
hand += card!($s);
)*
hand
}
};
}
#[macro_export]
macro_rules! combine_hands {
( $( $h: expr),* ) => {
{
let mut result = Hand::new();
$(
result += $h;
)*
result
}
}
}
#[macro_export]
macro_rules! deck {
() => {
Deck::new()
}
}
mod suit;
pub use suit::{Suit};
mod rank;
pub use rank::{Rank};
mod card;
pub use card::{Card};
mod cards;
pub use cards::{Cards, cards_of_suit, cards_of_rank};
mod deck;
pub use deck::{Deck};
mod hand;
pub use hand::{Hand};
#[cfg(test)]
mod tests;