Compare commits
2 Commits
99b49e629e
..
ai
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d5b982bba | |||
| 987d8bd0f4 |
Generated
+3
@@ -25,6 +25,7 @@ name = "card_game"
|
|||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -130,6 +131,7 @@ version = "0.3.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"card_game",
|
"card_game",
|
||||||
"rand",
|
"rand",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -238,6 +240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -72,10 +72,6 @@ impl Suit {
|
|||||||
pub const fn is_red(self) -> bool {
|
pub const fn is_red(self) -> bool {
|
||||||
self as u8 & 0b01 != 0
|
self as u8 & 0b01 != 0
|
||||||
}
|
}
|
||||||
/// Is the suit black.
|
|
||||||
pub const fn is_black(self) -> bool {
|
|
||||||
!self.is_red()
|
|
||||||
}
|
|
||||||
/// Suit value is 2 bits, is_red is the low bit.
|
/// Suit value is 2 bits, is_red is the low bit.
|
||||||
pub const fn suit_high_bit(self) -> bool {
|
pub const fn suit_high_bit(self) -> bool {
|
||||||
self as u8 & 0b10 != 0
|
self as u8 & 0b10 != 0
|
||||||
@@ -134,10 +130,6 @@ impl Rank {
|
|||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/// Numeric value: Ace = 1, King = 13.
|
|
||||||
pub const fn value(self) -> u8 {
|
|
||||||
self as u8
|
|
||||||
}
|
|
||||||
pub const fn checked_add(self, offset: u8) -> Option<Rank> {
|
pub const fn checked_add(self, offset: u8) -> Option<Rank> {
|
||||||
match (self as u8).checked_add(offset) {
|
match (self as u8).checked_add(offset) {
|
||||||
Some(rank) => Self::new(rank),
|
Some(rank) => Self::new(rank),
|
||||||
|
|||||||
Reference in New Issue
Block a user