Struct deckofcards::Hand
[−]
[src]
pub struct Hand { pub cards: Vec<Card>, }
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>
Methods
impl Hand
[src]
fn new() -> Hand
Make a new empty Hand
fn from_hand(hand: &Hand) -> Hand
Makes a Hand
from an existing hand
fn from_cards(cards: &[Card]) -> Hand
Makes a Hand
from a slice
fn from_strings(card_slice: &[&str]) -> Hand
Constructs a Hand
from a slice of strings with abbreviated card rank / suit values
fn push_card(&mut self, card: Card)
Adds one Card
to the Hand
fn push_cards(&mut self, cards: &[Card])
Adds zero or more cards to the Hand
fn push_hand(&mut self, other: &Hand)
Adds zero or more cards from some other Hand
fn len(&self) -> usize
Returns the number of cards
fn clear(&mut self)
Clears the Hand
(makes it empty)
fn remove(&mut self, index: usize) -> Card
Removes a Card
from the Hand
and returns it, panics if index does not exist
fn remove_cards(&mut self, cards: &[Card])
Removes the first instance of every matching card from the Hand
fn remove_card(&mut self, card: Card)
Removes first instance of the matching card from the Hand
fn cards_of_rank(&self, rank: Rank) -> Vec<Card>
Returns cards of the specified Rank
fn cards_of_suit(&self, suit: Suit) -> Vec<Card>
Returns cards of the specified Suit
Trait Implementations
impl Display for Hand
[src]
impl Clone for Hand
[src]
fn clone(&self) -> Hand
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<'a> AddAssign<&'a Hand> for Hand
[src]
fn add_assign(&mut self, rhs: &Hand)
The method for the +=
operator
impl AddAssign<Card> for Hand
[src]
fn add_assign(&mut self, rhs: Card)
The method for the +=
operator
impl Cards for Hand
[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