Deck

Trait Deck 

Source
pub trait Deck {
    type Card;

    // Required methods
    fn left(&self) -> usize;
    fn draw(&mut self) -> Self::Card;
    fn refill(&mut self);

    // Provided method
    fn try_draw(&mut self) -> Option<Self::Card> { ... }
}
Expand description

a Deck abstractly represents a source of distinct random elements.

Required Associated Types§

Required Methods§

Source

fn left(&self) -> usize

number of remaining cards in the deck.

Source

fn draw(&mut self) -> Self::Card

draw a random card from the deck.

panics if there are no more cards in the deck.

Source

fn refill(&mut self)

add all previously drawn cards back into the deck.

Provided Methods§

Source

fn try_draw(&mut self) -> Option<Self::Card>

draw a random card from the deck, returning None if the deck is empty.

Implementors§

Source§

impl<'a, R: Rng, T> Deck for SliceDeck<'a, R, T>

Source§

impl<R: Rng> Deck for IntDeck<R>

Source§

impl<R: Rng> Deck for RangeDeck<R>