#[repr(u8)]pub enum Rank {
Show 16 variants
None = 0,
LowAce = 1,
Deuce = 2,
Trey = 3,
Four = 4,
Five = 5,
Six = 6,
Seven = 7,
Eight = 8,
Nine = 9,
Ten = 10,
Jack = 11,
Knight = 12,
Queen = 13,
King = 14,
Ace = 15,
}
Expand description
wiki | Simple numeric enum for card ranks
Simple integer enum. 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 in the project.
Note that there are two slots for aces and a slot for knight/cavalier. See Ace and Knight @ wiki for details.
Variants§
None = 0
LowAce = 1
Deuce = 2
Trey = 3
Four = 4
Five = 5
Six = 6
Seven = 7
Eight = 8
Nine = 9
Ten = 10
Jack = 11
Knight = 12
Queen = 13
King = 14
Ace = 15
Implementations§
source§impl Rank
impl Rank
sourcepub const fn from_u8(v: u8) -> Rank
pub const fn from_u8(v: u8) -> Rank
Convert integer to rank
use onejoker::prelude::*;
assert_eq!(Rank::Deuce, Rank::from_u8(2));
sourcepub const fn from_char(c: char) -> Rank
pub const fn from_char(c: char) -> Rank
Convert character to rank
use onejoker::prelude::*;
assert_eq!(Rank::Trey, Rank::from_char('3'));
sourcepub const fn to_char(&self) -> char
pub const fn to_char(&self) -> char
Convert to char
use onejoker::prelude::*;
assert_eq!('4', Rank::Four.to_char());
sourcepub const fn name(&self) -> &str
pub const fn name(&self) -> &str
Produce “seven”, “jack”, etc.
use onejoker::prelude::*;
assert_eq!("seven", Rank::Seven.name());
Trait Implementations§
source§impl<'de> Deserialize<'de> for Rank
impl<'de> Deserialize<'de> for Rank
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 Rank
impl Ord for Rank
source§impl PartialEq for Rank
impl PartialEq for Rank
source§impl PartialOrd for Rank
impl PartialOrd for Rank
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 Rank
impl Eq for Rank
impl StructuralPartialEq for Rank
Auto Trait Implementations§
impl Freeze for Rank
impl RefUnwindSafe for Rank
impl Send for Rank
impl Sync for Rank
impl Unpin for Rank
impl UnwindSafe for Rank
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
)