[][src]Struct cardpack::Rank

pub struct Rank {
    pub weight: isize,
    pub name: FluentName,
}

Rank Struct for a Card. Examples of standard Card Ranks would include: Ace, Ten, and Deuce Joker, Death (Tarot), and Ober (Skat). The weight of the Rank determines how a Card is sorted relative to it's Suit.

There are four ways to instantiate a Rank, each of them having advantages:

As an instance variable

let ace = cardpack::Rank {
    weight: 1,
    name: cardpack::fluent_name::FluentName::new(cardpack::ACE),
};

This gives you maximum flexibility. Since the value of the Ace is 1, it will be sorted at the and of a Suit (unless there are any Cards with negative weights).

Rank::new() with a value string

let king = cardpack::Rank::new(cardpack::KING);

This sets the weight for the Rank based upon the default value as set in its fluent template entry.

Rank::new_with_weight()

let king = cardpack::Rank::new_with_weight(cardpack::QUEEN, 12);

Overrides the default weight for a Rank.

Rank::from_array()

let ranks: Vec<cardpack::Rank> = cardpack::Rank::from_array(&[cardpack::ACE, cardpack::TEN,]);

Returns a Vector of Ranks with their weights determined by the order they're passed in, high to low. This facilitates the easy creation of custom decks, such as pinochle.

Fields

weight: isize

Used by the Pile struct to sort Cards by their Suit and Rank.

name: FluentName

Implementations

impl Rank[src]

pub fn new(name: &'static str) -> Rank[src]

Returns a Rank, determining its weight by the default weight value for its name set in the fluent templates. For instance, if you look in `src/fluent/locales/core.ftl you will see that the default weight for an Ace is 14. This will mean that when a pile of cards is sorted that it will be at the top of a standard French Deck where the Ace is high.

Usage

let king = cardpack::Rank::new(cardpack::HERMIT);

pub fn new_with_weight(name: &'static str, weight: isize) -> Rank[src]

Returns a Rank instance with the passed in name and weight, overriding the default value set in the fluent templates.

Usage

let king = cardpack::Rank::new_with_weight(cardpack::QUEEN, 12);

pub fn from_array(s: &[&'static str]) -> Vec<Rank>[src]

Usage

let ranks: Vec<cardpack::Rank> = cardpack::Rank::from_array(&[
    cardpack::ACE, cardpack::TEN, cardpack::KING,
    cardpack::QUEEN, cardpack::JACK, cardpack::NINE]);

Returns a Vector of Ranks with their weights determined by the order they're passed in, high to low. This facilitates the easy creation of custom decks, such as for pinochle.

pub fn generate_canasta_ranks() -> Vec<Rank>[src]

pub fn generate_euchre_ranks() -> Vec<Rank>[src]

pub fn generate_french_ranks() -> Vec<Rank>[src]

pub fn generate_pinochle_ranks() -> Vec<Rank>[src]

pub fn generate_major_arcana_ranks() -> Vec<Rank>[src]

pub fn generate_minor_arcana_ranks() -> Vec<Rank>[src]

pub fn generate_skat_ranks() -> Vec<Rank>[src]

Trait Implementations

impl Clone for Rank[src]

impl Copy for Rank[src]

impl Debug for Rank[src]

impl Default for Rank[src]

impl Display for Rank[src]

impl Eq for Rank[src]

impl Hash for Rank[src]

impl Named for Rank[src]

impl Ord for Rank[src]

impl PartialEq<Rank> for Rank[src]

impl PartialOrd<Rank> for Rank[src]

impl StructuralEq for Rank[src]

impl StructuralPartialEq for Rank[src]

Auto Trait Implementations

impl RefUnwindSafe for Rank

impl Send for Rank

impl Sync for Rank

impl Unpin for Rank

impl UnwindSafe for Rank

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyEq for T where
    T: PartialEq<T> + Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,