#[repr(u8)]pub enum Suit {
None = 0,
Club = 1,
Diamond = 2,
Heart = 3,
Spade = 4,
}
Expand description
wiki | A simple numeric enum for card suits
Specific numbers do matter: I do a lot of math with them to optimize things, and the same numbers are used in the other languages.
Variants§
None = 0
Joker, etc.
Club = 1
Clubs / Batons / Acorns / Wands
Diamond = 2
Diamonds / Coins / Bells / Pentacles
Heart = 3
Hearts / Cups / Roses
Spade = 4
Spades / Swords / Leaves / Shields
Implementations§
source§impl Suit
impl Suit
sourcepub const fn from_u8(v: u8) -> Suit
pub const fn from_u8(v: u8) -> Suit
Convert integer to suit
use onejoker::prelude::*;
assert_eq!(Suit::Club, Suit::from_u8(1));
sourcepub const fn from_char(c: char) -> Suit
pub const fn from_char(c: char) -> Suit
Accept ASCII text or Unicode solid/black suit symbols U+2660, U+2665, U+2666, U+2663
use onejoker::prelude::*;
assert_eq!(Suit::Heart, Suit::from_char('h'));
assert_eq!(Suit::Club, Suit::from_char('♣'));
sourcepub const fn to_char(&self) -> char
pub const fn to_char(&self) -> char
Produce the ASCII version
use onejoker::prelude::*;
assert_eq!('d', Suit::Diamond.to_char());
sourcepub const fn to_symbol(&self) -> char
pub const fn to_symbol(&self) -> char
Produce the Unicode version
use onejoker::prelude::*;
assert_eq!('♠', Suit::Spade.to_symbol());
sourcepub const fn name(&self) -> &str
pub const fn name(&self) -> &str
Produce “club”, “diamond”, etc.
use onejoker::prelude::*;
assert_eq!("diamond", Suit::Diamond.name());
Trait Implementations§
source§impl<'de> Deserialize<'de> for Suit
impl<'de> Deserialize<'de> for Suit
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Suit
impl Ord for Suit
source§impl PartialEq for Suit
impl PartialEq for Suit
source§impl PartialOrd for Suit
impl PartialOrd for Suit
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Suit
impl Eq for Suit
impl StructuralPartialEq for Suit
Auto Trait Implementations§
impl Freeze for Suit
impl RefUnwindSafe for Suit
impl Send for Suit
impl Sync for Suit
impl Unpin for Suit
impl UnwindSafe for Suit
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)