Initial Commit for some cardstuffs
This commit is contained in:
64
card_stuffs/src/lib.rs
Normal file
64
card_stuffs/src/lib.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
pub enum Suit {
|
||||
Heart,
|
||||
Diamond,
|
||||
Club,
|
||||
Spade
|
||||
}
|
||||
|
||||
pub enum Value {
|
||||
Ace,
|
||||
Two,
|
||||
Three,
|
||||
Four,
|
||||
Five,
|
||||
Six,
|
||||
Seven,
|
||||
Eight,
|
||||
Nine,
|
||||
Ten,
|
||||
Jack,
|
||||
Queen,
|
||||
King
|
||||
}
|
||||
|
||||
impl Value {
|
||||
pub fn indexed_values(&self) -> u8 {
|
||||
match *self {
|
||||
Value::Ace => 1,
|
||||
Value::Two => 2,
|
||||
Value::Three => 3,
|
||||
Value::Four => 4,
|
||||
Value::Five => 5,
|
||||
Value::Six => 6,
|
||||
Value::Seven => 7,
|
||||
Value::Eight => 8,
|
||||
Value::Nine => 9,
|
||||
Value::Ten => 10,
|
||||
Value::Jack => 11,
|
||||
Value::Queen => 12,
|
||||
Value::King => 13,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Card {
|
||||
pub suit: Suit,
|
||||
pub value: Value,
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user