Struct cardpack::cards::decks::standard52::Standard52
source · pub struct Standard52 {
pub pack: Pack,
pub deck: Pile,
}
Expand description
Standard52
is a representation of a deck of cards used to play
most versions of poker. It is useful to determine if a Card
belongs
in the deck and to deserialize Cards, Piles and decks from index strings.
Fields§
§pack: Pack
§deck: Pile
Implementations§
source§impl Standard52
impl Standard52
sourcepub fn new_from_pile(pile: Pile) -> Result<Standard52, DeckError>
pub fn new_from_pile(pile: Pile) -> Result<Standard52, DeckError>
§Errors
Will return DeckError::PilePackMismatch
error if Pile
passed in isn’t a FrenchDeck
.
pub fn new_shuffled() -> Self
sourcepub fn from_index(card_str: &'static str) -> Result<Standard52, DeckError>
pub fn from_index(card_str: &'static str) -> Result<Standard52, DeckError>
§Errors
Will return DeckError::InvalidIndex
if passed in index is incomplete.
sourcepub fn pile_from_index(card_str: &'static str) -> Result<Pile, DeckError>
pub fn pile_from_index(card_str: &'static str) -> Result<Pile, DeckError>
§Errors
Will return DeckError::InvalidIndex
if passed in index is invalid.
sourcepub fn pile_from_index_validated(
card_str: &'static str
) -> Result<Pile, DeckError>
pub fn pile_from_index_validated( card_str: &'static str ) -> Result<Pile, DeckError>
Validating method that takes a Standard52
index string and returns a Pile
,
making sure that there are no duplicate valid cards in the string.
This method is doing a lot :-P
§Errors
Will return DeckError::InvalidIndex
if passed in index is invalid.
Will return DeckError::DuplicateCard
if the index has the same Card
more
than once.
§Panics
Should not be possible.
sourcepub fn pile_from_pile(&self, pile: Pile) -> Result<Pile, DeckError>
pub fn pile_from_pile(&self, pile: Pile) -> Result<Pile, DeckError>
§Errors
Will return DeckError::PilePackMismatch
if Pile
passed contains a card that isn’t
in the Standard52
deck.
pub fn draw(&mut self, x: usize) -> Option<Pile>
pub fn to_index(&self) -> String
pub fn to_index_str(&self) -> &'static str
pub fn to_symbol_index(&self) -> String
sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
A Standard52 deck is complete if a sorted Pile of the deck is equal to it’s Pack.
pub fn card_from_index(index: &'static str) -> Card
pub fn card_from_string(index: String) -> Card
pub fn is_valid_card(&self, card: &Card) -> bool
sourcepub fn sort_by_suit(pile: &Pile) -> HashMap<Suit, Pile>
pub fn sort_by_suit(pile: &Pile) -> HashMap<Suit, Pile>
Returns HashMap
of Piles of Cards sorted by the Standard52 Suits.
https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.entry// https://www.reddit.com/r/rust/comments/9xho3i/i_have_a_hashmap_that_pairs_strings_with_vectors//
Trait Implementations§
source§impl Clone for Standard52
impl Clone for Standard52
source§fn clone(&self) -> Standard52
fn clone(&self) -> Standard52
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Standard52
impl Debug for Standard52
source§impl Default for Standard52
impl Default for Standard52
source§fn default() -> Standard52
fn default() -> Standard52
source§impl Display for Standard52
impl Display for Standard52
source§impl Hash for Standard52
impl Hash for Standard52
source§impl PartialEq for Standard52
impl PartialEq for Standard52
source§fn eq(&self, other: &Standard52) -> bool
fn eq(&self, other: &Standard52) -> bool
self
and other
values to be equal, and is used
by ==
.