Initial Commit for some cardstuffs

This commit is contained in:
2025-02-24 21:42:06 +00:00
parent f0d851ebb3
commit 63452f76f9
5 changed files with 94 additions and 2 deletions

64
card_stuffs/src/lib.rs Normal file
View 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);
}
}