Struct rust_cards::hand::Hand [−][src]
Fields
vec: Vec<Card>
Implementations
returns a Hand containing a full deck
ordered 2, 3, 4, … J, Q, K, A Suits ordered Club(♣), Diamond(♦), Heart(♥), Spade(♠)
Randomizes the order of the hand
returns a new value; does not mutate the original value
reverses the hand i.e. the first index becomes the last index, the second index becomes the second-last index, etc.Hand
returns a new value; does not mutate the original value
removes the first indexed card in the hand and returns its value
mutates the hand; doesn’t return a new hand
let mut h = Hand::from( vec![ Card::new(Value::Ace, Suit::Spade) Card::new(Value::Two, Suit::Spade) Card::new(Value::Three, Suit::Spade) ] ); // A♠, 2♠, 3♠ let popped = h.pop(); // h == 2♠, 3♠ // popped == A♠
removes the last indexed card in the hand and returns its value
mutates the hand; doesn’t return a new hand
let mut h = Hand::from( vec![ Card::new(Value::Ace, Suit::Spade) Card::new(Value::Two, Suit::Spade) Card::new(Value::Three, Suit::Spade) ] ); // A♠, 2♠, 3♠ let popped = h.pop(); // h == A♠, 2♠ // popped == 3♠
Pushes a card to the top of the hand
let mut h = Hand::from( vec![ Card::new(Value::Ace, Suit::Spade) Card::new(Value::Two, Suit::Spade) Card::new(Value::Three, Suit::Spade) ] ); // A♠, 2♠, 3♠ h = h.push(Card::new(Value::King, Suit::Spade)) // K♠, A♠, 2♠, 3♠
Pushes a card to the bottom of the hand
let mut h = Hand::from( vec![ Card::new(Value::Ace, Suit::Spade) Card::new(Value::Two, Suit::Spade) Card::new(Value::Three, Suit::Spade) ] ); // A♠, 2♠, 3♠ h = h.push(Card::new(Value::Four, Suit::Spade)) // A♠, 2♠, 3♠, 4♠
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Hand
impl UnwindSafe for Hand
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V