Struct deckofcards::Hand

source ·
pub struct Hand {
    pub cards: Vec<Card>,
}
Expand description

A Hand is zero or more cards that represents some aspect of a game, e.g. the cards a person is holding. A hand may be shuffled or sorted and there are functions for adding or removing cards. Unlike a Deck, there is no concept of dealt or undealt cards.

Fields

cards: Vec<Card>

Implementations

Make a new empty Hand

Makes a Hand from an existing hand

Makes a Hand from a slice

Constructs a Hand from a slice of strings with abbreviated card rank / suit values

Adds one Card to the Hand

Adds zero or more cards to the Hand

Adds zero or more cards from some other Hand

Returns the number of cards

Clears the Hand (makes it empty)

Removes a Card from the Hand and returns it, panics if index does not exist

Removes the first instance of every matching card from the Hand

Removes first instance of the matching card from the Hand

Returns cards of the specified Rank

Returns cards of the specified Suit

Trait Implementations

Performs the += operation. Read more
Performs the += operation. Read more
Shuffle the cards into a random order
Sort the cards by suit and then by rank (low to high)
Sorts the cards by suit and then by rank (high to low)
Sort the cards by rank (high to low) and then by suit
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.