[−][src]Struct cardpack::Rank
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]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Named for Rank
[src]
fn name(&self) -> &str
[src]
fn fluent_value(&self, key_section: &str, lid: &LanguageIdentifier) -> String
[src]
fn index(&self, lid: &LanguageIdentifier) -> String
[src]
fn index_default(&self) -> String
[src]
fn long(&self, lid: &LanguageIdentifier) -> String
[src]
fn long_default(&self) -> String
[src]
fn default_weight(&self) -> isize
[src]
impl Ord for Rank
[src]
fn cmp(&self, other: &Rank) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Rank> for Rank
[src]
impl PartialOrd<Rank> for Rank
[src]
fn partial_cmp(&self, other: &Rank) -> Option<Ordering>
[src]
fn lt(&self, other: &Rank) -> bool
[src]
fn le(&self, other: &Rank) -> bool
[src]
fn gt(&self, other: &Rank) -> bool
[src]
fn ge(&self, other: &Rank) -> bool
[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]
T: 'static + ?Sized,
impl<T> AnyEq for T where
T: PartialEq<T> + Any,
T: PartialEq<T> + Any,
pub fn equals(&self, other: &(dyn Any + 'static)) -> bool
pub fn as_any(&self) -> &(dyn Any + 'static)
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,