pub struct Hand {
pub master: &'static MasterDeck,
pub cards: Vec<Card>,
}
Expand description
wiki | Hand of cards
A simple array of card objects with some utility methods.
It is expected that most access will go through push
/pop``, which are fast, though things line
insertand
remove` are available.
Fields§
§master: &'static MasterDeck
Associated MasterDeck
cards: Vec<Card>
Current contents
Implementations§
source§impl Hand
impl Hand
sourcepub fn from_slice(cards: &[Card]) -> Hand
pub fn from_slice(cards: &[Card]) -> Hand
Create a new Hand associated with the default MasterDeck containing the cards given in the iterator.
sourcepub fn from_text(text: &str) -> Hand
pub fn from_text(text: &str) -> Hand
Create a new Hand associated with the default MasterDeck containing the hand given in text form.
sourcepub fn copy_from_slice(&self, cards: &[Card]) -> Hand
pub fn copy_from_slice(&self, cards: &[Card]) -> Hand
sourcepub fn copy_from_text(&self, text: &str) -> Hand
pub fn copy_from_text(&self, text: &str) -> Hand
sourcepub fn is_not_empty(&self) -> bool
pub fn is_not_empty(&self) -> bool
Is the hand not empty?
sourcepub fn valid_card(&self, cin: Card) -> Option<Card>
pub fn valid_card(&self, cin: Card) -> Option<Card>
Given a Card, return the same card if valid for our MasterDeck or panic. Correct ace values if needed.
sourcepub fn card_at(&self, index: usize) -> Option<Card>
pub fn card_at(&self, index: usize) -> Option<Card>
Return the Card at the given index, or None
if out of range.
sourcepub fn set_card_at(&mut self, index: usize, card: Card) -> bool
pub fn set_card_at(&mut self, index: usize, card: Card) -> bool
Set the Card at the given index, or return false
if out of range.
sourcepub fn push_n<I>(&mut self, n: usize, iter: I) -> boolwhere
I: IntoIterator<Item = Card>,
pub fn push_n<I>(&mut self, n: usize, iter: I) -> boolwhere
I: IntoIterator<Item = Card>,
Push a collection of Cards onto the end of the hand.
sourcepub fn pop_n(&mut self, n: usize) -> impl Iterator<Item = Card>
pub fn pop_n(&mut self, n: usize) -> impl Iterator<Item = Card>
Pop n
Cards from the end of the hand.
sourcepub fn insert_at(&mut self, index: usize, card: Card) -> bool
pub fn insert_at(&mut self, index: usize, card: Card) -> bool
Insert a Card at the given index.
sourcepub fn remove_card(&mut self, card: Card) -> bool
pub fn remove_card(&mut self, card: Card) -> bool
Remove the given Card from the hand if present.
sourcepub fn combinations(&self, k: usize) -> impl Iterator<Item = Hand>
pub fn combinations(&self, k: usize) -> impl Iterator<Item = Hand>
Return an iterator over all n
-card combinations of the hand.
sourcepub fn equals(&self, other: &Self) -> bool
pub fn equals(&self, other: &Self) -> bool
Return true if the hands are identical: i.e., same cards in same order.
sourcepub fn is_equivalent_to(&self, other: &Self) -> bool
pub fn is_equivalent_to(&self, other: &Self) -> bool
Return true if the hands are equivalent: i.e., same cards in any order.
sourcepub fn ace_fix(&mut self)
pub fn ace_fix(&mut self)
Fix the ace values in the Hand to match the MasterDeck.
sourcepub fn draw(&mut self, n: usize, d: &mut Deck) -> bool
pub fn draw(&mut self, n: usize, d: &mut Deck) -> bool
Take n
cards from the given Deck and add them to the hand.
Trait Implementations§
source§impl<'a> IntoIterator for &'a Hand
impl<'a> IntoIterator for &'a Hand
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)