[][src]Struct bridge_deck::Cards

pub struct Cards { /* fields omitted */ }

A deck or hand of cards

This data structure assumes that each card can appear only once, as in the game bridge. If you want to allow more than one deck mixed together you want a different crate. Because each card can only appear once, Cards is Copy and only takes 64 bits. This makes it fast and memory efficient.

Implementations

impl Cards[src]

pub const fn len(&self) -> usize[src]

How many cards are there?

pub fn insert(&mut self, card: Card)[src]

insert a card to the deck or hand

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

Check if we contain a card

pub fn union(&self, cards: Cards) -> Cards

Notable traits for Cards

impl Iterator for Cards type Item = Card;
[src]

Join two stacks of cards together

pub fn pick(&mut self, num: usize) -> Option<Cards>[src]

Randomly pick num cards to remove from the deck. Returns None only if there aren't enough cards.

pub const ALL: Cards[src]

All 52 cards.

pub const EMPTY: Cards[src]

A deck or hand with no cards in it.

Trait Implementations

impl Clone for Cards[src]

impl Copy for Cards[src]

impl Debug for Cards[src]

impl Eq for Cards[src]

impl Iterator for Cards[src]

type Item = Card

The type of the elements being iterated over.

impl PartialEq<Cards> for Cards[src]

impl StructuralEq for Cards[src]

impl StructuralPartialEq for Cards[src]

Auto Trait Implementations

impl RefUnwindSafe for Cards

impl Send for Cards

impl Sync for Cards

impl Unpin for Cards

impl UnwindSafe for Cards

Blanket Implementations

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

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<I> IteratorRandom for I where
    I: Iterator
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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>,