[−][src]Struct deckofcards::Card
A Card
has a Rank
and a Suit
and represents a card from the normal 52-card
playing deck.
Example
use deckofcards::{Card, Rank, Suit}; let card = Card::new(Rank::Jack, Suit::Hearts);
Fields
rank: Rank
The card's Rank
, e.g. Jack
suit: Suit
The card's Suit
, e.g. Hearts
Methods
impl Card
[src]
pub fn new(rank: Rank, suit: Suit) -> Card
[src]
Creates a card with the given suit and rank
pub fn cmp_rank_then_suit(&self, other: &Card) -> Ordering
[src]
Compares by rank and then suit
pub fn cmp_desc_rank_then_suit(&self, other: &Card) -> Ordering
[src]
Compares by descending rank and then suit
pub fn cmp_suit_then_rank(&self, other: &Card) -> Ordering
[src]
Compares by suit and then rank
pub fn cmp_suit_then_desc_rank(&self, other: &Card) -> Ordering
[src]
Compares by suit and then rank
pub fn from_str(s: &str) -> Result<Card, &'static str>
[src]
Creates a card from a string such, e.g. "AS" returns Ace of Spades
pub fn to_str(&self) -> String
[src]
Turns the card into a short string consisting of rank, suit, e.g. "AS"
pub fn name(&self) -> String
[src]
Returns an English formatted name of the card, e.g. "Ace of Spades"
pub fn ordinal(&self) -> usize
[src]
Returns an ordinal for the card which is a unique number which can be used for indexing
pub fn is_hearts(&self) -> bool
[src]
Tests if the card is Hearts
pub fn is_clubs(&self) -> bool
[src]
Tests if the card is Clubs
pub fn is_spades(&self) -> bool
[src]
Tests if the card is Spades
pub fn is_diamonds(&self) -> bool
[src]
Tests if the card is Diamonds
pub fn all_cards() -> &'static [Card]
[src]
Returns an array slice containing all the cards in a standard 52-card deck
pub fn iterator() -> Iter<'static, Card>
[src]
Trait Implementations
impl AddAssign<Card> for Hand
[src]
fn add_assign(&mut self, rhs: Card)
[src]
impl Clone for Card
[src]
impl Copy for Card
[src]
impl Debug for Card
[src]
impl Display for Card
[src]
impl Eq for Card
[src]
impl Hash for Card
[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 Ord for Card
[src]
fn cmp(&self, other: &Card) -> Ordering
[src]
Sorts by rank and then suit
#[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<Card> for Card
[src]
impl PartialOrd<Card> for Card
[src]
fn partial_cmp(&self, other: &Card) -> Option<Ordering>
[src]
fn lt(&self, other: &Card) -> bool
[src]
fn le(&self, other: &Card) -> bool
[src]
fn gt(&self, other: &Card) -> bool
[src]
fn ge(&self, other: &Card) -> bool
[src]
impl StructuralEq for Card
[src]
impl StructuralPartialEq for Card
[src]
Auto Trait Implementations
impl RefUnwindSafe for Card
impl Send for Card
impl Sync for Card
impl Unpin for Card
impl UnwindSafe for Card
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
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.
fn to_owned(&self) -> T
[src]
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.
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.
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>,