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§
Source§impl Hand
impl Hand
Sourcepub fn from_cards(cards: &[Card]) -> Hand
pub fn from_cards(cards: &[Card]) -> Hand
Makes a Hand
from a slice
Sourcepub fn from_strings(card_slice: &[&str]) -> Hand
pub fn from_strings(card_slice: &[&str]) -> Hand
Constructs a Hand
from a slice of strings with abbreviated card rank / suit values
Sourcepub fn push_cards(&mut self, cards: &[Card])
pub fn push_cards(&mut self, cards: &[Card])
Adds zero or more cards to the Hand
Sourcepub fn remove(&mut self, index: usize) -> Card
pub fn remove(&mut self, index: usize) -> Card
Removes a Card
from the Hand
and returns it, panics if index does not exist
Sourcepub fn remove_cards(&mut self, cards: &[Card])
pub fn remove_cards(&mut self, cards: &[Card])
Removes the first instance of every matching card from the Hand
Sourcepub fn remove_all_cards(&mut self, cards: &[Card])
pub fn remove_all_cards(&mut self, cards: &[Card])
Removes the every instance of every matching card from the Hand
Sourcepub fn remove_card(&mut self, card: &Card) -> bool
pub fn remove_card(&mut self, card: &Card) -> bool
Removes first instance of the matching card from the Hand
Sourcepub fn cards_of_rank(&self, rank: Rank) -> Vec<Card>
pub fn cards_of_rank(&self, rank: Rank) -> Vec<Card>
Returns cards of the specified Rank
Sourcepub fn cards_of_suit(&self, suit: Suit) -> Vec<Card>
pub fn cards_of_suit(&self, suit: Suit) -> Vec<Card>
Returns cards of the specified Suit
Trait Implementations§
Source§impl<'a> AddAssign<&'a Hand> for Hand
impl<'a> AddAssign<&'a Hand> for Hand
Source§fn add_assign(&mut self, rhs: &Hand)
fn add_assign(&mut self, rhs: &Hand)
Performs the
+=
operation. Read moreSource§impl AddAssign<Card> for Hand
impl AddAssign<Card> for Hand
Source§fn add_assign(&mut self, rhs: Card)
fn add_assign(&mut self, rhs: Card)
Performs the
+=
operation. Read moreSource§impl Cards for Hand
impl Cards for Hand
Source§fn sort_suit_ascending_rank(&mut self)
fn sort_suit_ascending_rank(&mut self)
Sort the cards by suit and then by rank (low to high)
Source§fn sort_suit_descending_rank(&mut self)
fn sort_suit_descending_rank(&mut self)
Sorts the cards by suit and then by rank (high to low)
Source§fn sort_descending_rank_suit(&mut self)
fn sort_descending_rank_suit(&mut self)
Sort the cards by rank (high to low) and then by suit
Auto Trait Implementations§
impl Freeze for Hand
impl RefUnwindSafe for Hand
impl Send for Hand
impl Sync for Hand
impl Unpin for Hand
impl UnwindSafe for Hand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more