[−][src]Struct deckofcards::Hand
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]
fn add_assign(&mut self, rhs: &Hand)
[src]
impl AddAssign<Card> for Hand
[src]
fn add_assign(&mut self, rhs: Card)
[src]
impl Cards for Hand
[src]
fn cards(&self) -> &[Card]
[src]
fn mut_cards(&mut self) -> &mut [Card]
[src]
fn shuffle(&mut self)
[src]
fn sort_suit_ascending_rank(&mut self)
[src]
fn sort_suit_descending_rank(&mut self)
[src]
fn sort_descending_rank_suit(&mut self)
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,