[][src]Struct deckofcards::Hand

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]

pub fn new() -> Self[src]

Create an empty hand

pub fn from_hand(hand: &Hand) -> Hand[src]

Makes a Hand from an existing hand

pub fn from_cards(cards: &[Card]) -> Hand[src]

Makes a Hand from a slice

pub fn from_strings(card_slice: &[&str]) -> Hand[src]

Constructs a Hand from a slice of strings with abbreviated card rank / suit values

pub fn push_card(&mut self, card: Card)[src]

Adds one Card to the Hand

pub fn push_cards(&mut self, cards: &[Card])[src]

Adds zero or more cards to the Hand

pub fn push_hand(&mut self, other: &Hand)[src]

Adds zero or more cards from some other Hand

pub fn len(&self) -> usize[src]

Returns the number of cards

pub fn clear(&mut self)[src]

Clears the Hand (makes it empty)

pub fn remove(&mut self, index: usize) -> Card[src]

Removes a Card from the Hand and returns it, panics if index does not exist

pub fn remove_cards(&mut self, cards: &[Card])[src]

Removes the first instance of every matching card from the Hand

pub fn remove_all_cards(&mut self, cards: &[Card])[src]

Removes the every instance of every matching card from the Hand

pub fn remove_card(&mut self, card: &Card) -> bool[src]

Removes first instance of the matching card from the Hand

pub fn cards_of_rank(&self, rank: Rank) -> Vec<Card>[src]

Returns cards of the specified Rank

pub fn cards_of_suit(&self, suit: Suit) -> Vec<Card>[src]

Returns cards of the specified Suit

Trait Implementations

impl<'a> AddAssign<&'a Hand> for Hand[src]

impl AddAssign<Card> for Hand[src]

impl Cards for Hand[src]

impl Clone for Hand[src]

impl Default for Hand[src]

impl Display for Hand[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,