Struct stochasta::playing_cards::PlayingCard
source · pub struct PlayingCard { /* private fields */ }
Expand description
A standard playing card like 10♥ consisting of
a PlayingCardValue
and
a PlayingCardSuit
.
Implementations§
source§impl PlayingCard
impl PlayingCard
sourcepub fn new(value: PlayingCardValue, suit: PlayingCardSuit) -> Self
pub fn new(value: PlayingCardValue, suit: PlayingCardSuit) -> Self
Creates a new playing card.
Example
use stochasta::playing_cards::{PlayingCard, PlayingCardSuit, PlayingCardValue};
let card = PlayingCard::new(PlayingCardValue::King, PlayingCardSuit::Hearts);
assert_eq!(card.value(), PlayingCardValue::King);
assert_eq!(card.suit(), PlayingCardSuit::Hearts);
sourcepub fn value(&self) -> PlayingCardValue
pub fn value(&self) -> PlayingCardValue
Returns the value of the card
Example
use stochasta::playing_cards::{PlayingCard, PlayingCardSuit, PlayingCardValue};
assert_eq!(
PlayingCard::new(PlayingCardValue::King, PlayingCardSuit::Hearts).value(),
PlayingCardValue::King
);
sourcepub fn suit(&self) -> PlayingCardSuit
pub fn suit(&self) -> PlayingCardSuit
Returns the suit of the card
Example
use stochasta::playing_cards::{PlayingCard, PlayingCardSuit, PlayingCardValue};
assert_eq!(
PlayingCard::new(PlayingCardValue::King, PlayingCardSuit::Hearts).suit(),
PlayingCardSuit::Hearts
);
Trait Implementations§
source§impl Clone for PlayingCard
impl Clone for PlayingCard
source§fn clone(&self) -> PlayingCard
fn clone(&self) -> PlayingCard
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PlayingCard
impl Debug for PlayingCard
source§impl Default for PlayingCard
impl Default for PlayingCard
source§fn default() -> PlayingCard
fn default() -> PlayingCard
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for PlayingCard
impl<'de> Deserialize<'de> for PlayingCard
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for PlayingCard
impl Display for PlayingCard
source§impl Hash for PlayingCard
impl Hash for PlayingCard
source§impl Ord for PlayingCard
impl Ord for PlayingCard
source§fn cmp(&self, other: &PlayingCard) -> Ordering
fn cmp(&self, other: &PlayingCard) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<PlayingCard> for PlayingCard
impl PartialEq<PlayingCard> for PlayingCard
source§fn eq(&self, other: &PlayingCard) -> bool
fn eq(&self, other: &PlayingCard) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<PlayingCard> for PlayingCard
impl PartialOrd<PlayingCard> for PlayingCard
source§fn partial_cmp(&self, other: &PlayingCard) -> Option<Ordering>
fn partial_cmp(&self, other: &PlayingCard) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for PlayingCard
impl Serialize for PlayingCard
impl Copy for PlayingCard
impl Eq for PlayingCard
impl StructuralEq for PlayingCard
impl StructuralPartialEq for PlayingCard
Auto Trait Implementations§
impl RefUnwindSafe for PlayingCard
impl Send for PlayingCard
impl Sync for PlayingCard
impl Unpin for PlayingCard
impl UnwindSafe for PlayingCard
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more