Struct deckofcards::Card
[−]
[src]
pub struct Card { pub rank: Rank, pub suit: Suit, }
A Card
has a Rank
and a Suit
and represents a card from the normal 52-card
playing deck.
Example
let card = Card::new(Rank::Jack, Suit::Hearts);
Fields
rank: Rank
The card's Rank
, e.g. Jack
suit: Suit
The card's Suit
, e.g. Hearts
Methods
impl Card
[src]
fn new(rank: Rank, suit: Suit) -> Card
Creates a card with the given suit and rank
fn cmp_rank_then_suit(&self, other: &Card) -> Ordering
Compares by rank and then suit
fn cmp_desc_rank_then_suit(&self, other: &Card) -> Ordering
Compares by descending rank and then suit
fn cmp_suit_then_rank(&self, other: &Card) -> Ordering
Compares by suit and then rank
fn cmp_suit_then_desc_rank(&self, other: &Card) -> Ordering
Compares by suit and then rank
fn from_str(s: &str) -> Result<Card, &'static str>
Creates a card from a string such, e.g. "AS" returns Ace of Spades
fn to_str(&self) -> String
Turns the card into a short string consisting of rank, suit, e.g. "AS"
fn name(&self) -> String
Returns an English formatted name of the card, e.g. "Ace of Spades"
fn ordinal(&self) -> usize
Returns an ordinal for the card which is a unique number which can be used for indexing
fn is_hearts(&self) -> bool
Tests if the card is Hearts
fn is_clubs(&self) -> bool
Tests if the card is Clubs
fn is_spades(&self) -> bool
Tests if the card is Spades
fn is_diamonds(&self) -> bool
Tests if the card is Diamonds
fn all_cards() -> &'static [Card]
Returns an array slice containing all the cards in a standard 52-card deck
fn iterator() -> Iter<'static, Card>
Trait Implementations
impl Copy for Card
[src]
impl Clone for Card
[src]
fn clone(&self) -> Card
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Hash for Card
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Card
[src]
fn eq(&self, __arg_0: &Card) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Card) -> bool
This method tests for !=
.
impl Eq for Card
[src]
impl PartialOrd for Card
[src]
fn partial_cmp(&self, __arg_0: &Card) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Card) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Card) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Card) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Card) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more