Struct deckofcards::Deck

source ·
pub struct Deck { /* private fields */ }
Expand description

The Deck represents a deck of zero or more cards. Internally the deck consists of an undealt and a dealt pile of cards. The undealt pile starts off empty and receives cards as they are dealt from the undealt pile.

The deck may be reset to return it to its original state. A deck may be shuffled to randomize its order.

A deck can contain more than one card with the same rank / suit combination.

A deck cannot have more cards added or removed to it once it is created.

Implementations

Creates a new Deck containing the standard set of 52 cards

Creates a new Deck containing the specified cards

Returns the number of remaining undealt cards in the Deck

Returns the number of dealt cards in the Deck

Returns the number of cards, dealt or undealt, within the Deck

Returns the collection of dealt cards

Tells you the top card (very next to be drawn) in the undealt deck without dealing it.

Tells you the bottom card (very last to be drawn) in the undealt deck without dealing it.

Deals the card from the undealt pile. If there are no cards left, the function will return an error.

Deals one or more card from the undealt pile and returns them as an array.

Deals one or more card straight to the Hand. Returns the number of cards dealt.

Return the dealt cards back to the end of the undealt pile. Order is preserved according to the default order or the last shuffle.

Resets and shuffles the deck

Trait Implementations

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

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
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.