Struct deckofcards::Hand
source · 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
sourceimpl 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_card(&mut self, card: Card)
pub fn remove_card(&mut self, card: Card)
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
sourceimpl<'a> AddAssign<&'a Hand> for Hand
impl<'a> AddAssign<&'a Hand> for Hand
sourcefn add_assign(&mut self, rhs: &Hand)
fn add_assign(&mut self, rhs: &Hand)
Performs the
+=
operation. Read moresourceimpl AddAssign<Card> for Hand
impl AddAssign<Card> for Hand
sourcefn add_assign(&mut self, rhs: Card)
fn add_assign(&mut self, rhs: Card)
Performs the
+=
operation. Read moresourceimpl Cards for Hand
impl Cards for Hand
fn cards(&self) -> &[Card]
fn mut_cards(&mut self) -> &mut [Card]
sourcefn 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)
sourcefn 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)
sourcefn 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 RefUnwindSafe for Hand
impl Send for Hand
impl Sync for Hand
impl Unpin for Hand
impl UnwindSafe for Hand
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more