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

The card's Rank, e.g. Jack

The card's Suit, e.g. Hearts

Methods

impl Card
[src]

Creates a card with the given suit and rank

Compares by rank and then suit

Compares by descending rank and then suit

Compares by suit and then rank

Compares by suit and then rank

Creates a card from a string such, e.g. "AS" returns Ace of Spades

Turns the card into a short string consisting of rank, suit, e.g. "AS"

Returns an English formatted name of the card, e.g. "Ace of Spades"

Returns an ordinal for the card which is a unique number which can be used for indexing

Tests if the card is Hearts

Tests if the card is Clubs

Tests if the card is Spades

Tests if the card is Diamonds

Returns an array slice containing all the cards in a standard 52-card deck

Trait Implementations

impl Copy for Card
[src]

impl Clone for Card
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Hash for Card
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for Card
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Card
[src]

impl PartialOrd for Card
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Debug for Card
[src]

Formats the value using the given formatter.

impl Display for Card
[src]

Formats the value using the given formatter. Read more

impl Ord for Card
[src]

Sorts by rank and then suit