Struct cardpack::cards::pack::Pack

source ·
pub struct Pack { /* private fields */ }
Expand description

A Pack is an immutable pile of cards. Packs are designed to be a flexible representation of a deck, stack, discard pile, or hand.

Packs available are for a traditional 52 card French Deck, pinochle, spades, skat and tarot.

§Usage:

let pack = cardpack::Pack::french_deck();

let mut shuffled = pack.cards().shuffle();
let sb = shuffled.draw(2).unwrap();
let bb = shuffled.draw(2).unwrap();

println!("small blind: {}", sb.to_symbol_index());
println!("big blind:   {}", bb);

println!();
println!("flop : {}", shuffled.draw(3).unwrap());
println!("turn : {}", shuffled.draw(1).unwrap());
println!("river: {}", shuffled.draw(1).unwrap());

Implementations§

source§

impl Pack

source

pub fn is_complete(&self, piles: &[Pile]) -> bool

Returns true of the combined Cards from the passed in Vector match the Cards in the Pack.

source

pub fn cards(&self) -> &Pile

Returns a reference to the cards in the Pack.

source

pub fn contains(&self, card: &Card) -> bool

Returns true if the passed in Card is a part of the Pack.

source

pub fn canasta_deck() -> Self

source

pub fn euchre_deck() -> Self

source

pub fn hand_and_foot_deck() -> Self

source

pub fn french_deck() -> Self

source

pub fn french_deck_with_jokers() -> Self

source

pub fn pinochle_deck() -> Self

source

pub fn short_deck() -> Self

source

pub fn skat_deck() -> Self

source

pub fn spades_deck() -> Self

source

pub fn tarot_deck() -> Self

Trait Implementations§

source§

impl Clone for Pack

source§

fn clone(&self) -> Pack

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Pack

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Pack

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Pack

source§

fn eq(&self, other: &Pack) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Pack

Auto Trait Implementations§

§

impl Freeze for Pack

§

impl RefUnwindSafe for Pack

§

impl Send for Pack

§

impl Sync for Pack

§

impl Unpin for Pack

§

impl UnwindSafe for Pack

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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

source§

fn vzip(self) -> V