pub struct Card {
pub weight: u32,
pub index: String,
pub suit: Suit,
pub rank: Rank,
}
Expand description
Card
is the core struct in the library. A Card is made up of a Rank,
a Suit
, weight
, which is an integer that controls how a card is sorted
in a Pile
or as a part of a Vector
, and index, which is a short String
representation of the card, suitable for serialization in text format.
Fields§
§weight: u32
Used by the Pile struct to sort Cards.
index: String
The identity indicator in the corner of a playing card, such as AS
for ace of spades.
suit: Suit
§rank: Rank
Implementations§
source§impl Card
impl Card
sourcepub fn new(rank: Rank, suit: Suit) -> Self
pub fn new(rank: Rank, suit: Suit) -> Self
Instantiates a Card with the weight determined by the passed in Rank and Suit.
sourcepub fn from_index_strings(rank: &'static str, suit: &'static str) -> Self
pub fn from_index_strings(rank: &'static str, suit: &'static str) -> Self
Instantiates a new Card with the default weight as defined in the fluent templates.
sourcepub fn to_rank_weight(&self) -> Self
pub fn to_rank_weight(&self) -> Self
Returns a Card where the sorting emphasizes its Rank
weight over its Suit
weight.
So K♥ A♥ A♠ K♠
would return A♠ A♥ K♠ K♥
instead of A♠ K♠ A♥ K♥
.
sourcepub fn shift_rank_weight_left(&self, i: usize) -> Self
pub fn shift_rank_weight_left(&self, i: usize) -> Self
Returns a version of the Card
, with a geometric Rank
weighted operation
has been performed on it.
sourcepub fn symbol(&self, lid: &LanguageIdentifier) -> String
pub fn symbol(&self, lid: &LanguageIdentifier) -> String
Returns a Symbol String for the Card.
sourcepub fn symbol_colorized(&self, lid: &LanguageIdentifier) -> String
pub fn symbol_colorized(&self, lid: &LanguageIdentifier) -> String
Returns a Symbol String for the Card in the traditional colors for the Suits.
pub fn blank_card() -> Self
Trait Implementations§
source§impl FromIterator<Card> for Pile
impl FromIterator<Card> for Pile
source§impl FromIterator<Card> for Standard52Set
impl FromIterator<Card> for Standard52Set
source§impl Named for Card
impl Named for Card
fn name(&self) -> &str
source§fn index(&self, lid: &LanguageIdentifier) -> String
fn index(&self, lid: &LanguageIdentifier) -> String
source§fn long(&self, lid: &LanguageIdentifier) -> String
fn long(&self, lid: &LanguageIdentifier) -> String
source§fn default_weight(&self) -> u32
fn default_weight(&self) -> u32
source§fn fluent_value(&self, key_section: &str, lid: &LanguageIdentifier) -> String
fn fluent_value(&self, key_section: &str, lid: &LanguageIdentifier) -> String
source§fn index_default(&self) -> String
fn index_default(&self) -> String
US_ENGLISH
value of the names’ index value in the fluent templates. Read moresource§fn long_default(&self) -> String
fn long_default(&self) -> String
US_ENGLISH
value of the names’ long value in the fluent templates.fn default_prime(&self) -> u32
source§impl Ord for Card
impl Ord for Card
source§impl PartialEq for Card
impl PartialEq for Card
source§impl PartialOrd for Card
impl PartialOrd for Card
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more