Struct deckofcards::Deck
[−]
[src]
pub struct Deck { /* fields omitted */ }
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.
Methods
impl Deck
[src]
fn new() -> Deck
Creates a new Deck
containing the standard set of 52 cards
fn from_cards(cards: &[Card]) -> Deck
Creates a new Deck
containing the specified cards
fn undealt_count(&self) -> usize
Returns the number of remaining undealt cards in the Deck
fn dealt_count(&self) -> usize
Returns the number of dealt cards in the Deck
fn count(&self) -> usize
Returns the number of cards, dealt or undealt, within the Deck
fn dealt_cards(&self) -> &[Card]
Returns the collection of dealt cards
fn deal_one(&mut self) -> Result<Card, &'static str>
Deals the card from the undealt pile. If there are no cards left, the function will return an error.
fn deal(&mut self, numcards: usize) -> Vec<Card>
Deals one or more card from the undealt pile and returns them as an array.
fn deal_to_hand(&mut self, hand: &mut Hand, numcards: usize) -> usize
Deals one or more card straight to the Hand
. Returns the number of cards dealt.
fn reset(&mut self)
Return the dealt cards back to the end of the undealt pile. Order is preserved according to the default order or the last shuffle.
fn reset_shuffle(&mut self)
Resets and shuffles the deck
Trait Implementations
impl Cards for Deck
[src]
fn cards(&self) -> &[Card]
fn mut_cards(&mut self) -> &mut [Card]
fn shuffle(&mut self)
Shuffle the cards into a random order
fn sort_suit_ascending_rank(&mut self)
Sort the cards by suit and then by rank (low to high)
fn sort_suit_descending_rank(&mut self)
Sorts the cards by suit and then by rank (high to low)
fn sort_descending_rank_suit(&mut self)
Sort the cards by rank (high to low) and then by suit
impl Clone for Deck
[src]
fn clone(&self) -> Deck
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