Struct card_deck::deck::Deck [−][src]
pub struct Deck<C> { /* fields omitted */ }
A Deck of cards
Methods
impl<C> Deck<C>
[src]
impl<C> Deck<C>
pub fn new(v: Vec<C>) -> Self
[src]
pub fn new(v: Vec<C>) -> Self
Builds a deck using the supplied cards and defaults for all other options
pub fn build() -> DeckBuilder<C>
[src]
pub fn build() -> DeckBuilder<C>
Creates a Builder for the Deck, see DeckBuilder
pub fn put_discard(&mut self, card: C)
[src]
pub fn put_discard(&mut self, card: C)
Add a card to the discard pile
pub fn discards_to_bottom(&mut self)
[src]
pub fn discards_to_bottom(&mut self)
Adds the Discard Pile to the bottom of the draw pile, shuffling if shuffle_discards
use card_deck::Deck; let mut dk = Deck::build() .draw_pile(vec![1,2,3]) .discard_pile(vec![4]) .stop_on_discards(true).done(); assert_eq!(dk.len(),3); assert_eq!(dk.discard_len(),1); dk.discards_to_bottom(); assert_eq!(dk.len(),4); assert_eq!(dk.discard_len(),0); assert_eq!(dk.draw_all().last(),Some(4));
pub fn shuffle_draw_pile(&mut self)
[src]
pub fn shuffle_draw_pile(&mut self)
pub fn draw_1(&mut self) -> Option<C>
[src]
pub fn draw_1(&mut self) -> Option<C>
Returns None if nothing to draw
pub fn draw(&mut self, n: usize) -> Drain<C>
[src]
pub fn draw(&mut self, n: usize) -> Drain<C>
pub fn draw_all(&mut self) -> Drain<C>
[src]
pub fn draw_all(&mut self) -> Drain<C>
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
returns the maximum number of cards that can be drawn in a single draw
pub fn draw_len(&self) -> usize
[src]
pub fn draw_len(&self) -> usize
pub fn discard_len(&self) -> usize
[src]
pub fn discard_len(&self) -> usize
pub fn push_bottom(&mut self, c: C)
[src]
pub fn push_bottom(&mut self, c: C)
pub fn push_top(&mut self, c: C)
[src]
pub fn push_top(&mut self, c: C)
pub fn push_discards(&mut self, c: C)
[src]
pub fn push_discards(&mut self, c: C)
pub fn push_discards_top(&mut self, c: C)
[src]
pub fn push_discards_top(&mut self, c: C)
pub fn dig_for<F>(&mut self, f: F) -> Option<C> where
F: FnMut(&C) -> bool,
[src]
pub fn dig_for<F>(&mut self, f: F) -> Option<C> where
F: FnMut(&C) -> bool,
pub fn dig_all<F>(&mut self, f: F) -> IntoIter<C> where
F: FnMut(&C) -> bool,
[src]
pub fn dig_all<F>(&mut self, f: F) -> IntoIter<C> where
F: FnMut(&C) -> bool,
Currently slow, as for each found element has to do slow remove, When drain_filter is off nightly will be fixed to use that. Dont rely on this returning an IntoIter, but expect an Iterator of some form
Trait Implementations
impl<C: Debug> Debug for Deck<C>
[src]
impl<C: Debug> Debug for Deck<C>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<C: Clone> Clone for Deck<C>
[src]
impl<C: Clone> Clone for Deck<C>
fn clone(&self) -> Deck<C>
[src]
fn clone(&self) -> Deck<C>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a, C> IntoIterator for &'a Deck<C>
[src]
impl<'a, C> IntoIterator for &'a Deck<C>
Peeking cards
use card_deck::Deck; let dk = Deck::build().draw_pile(vec![1,2,3]).discard_pile(vec![4]).done(); let mut n = 0; for c in &dk{ n += c; } assert_eq!(n,10); //with stop_on_discards let dk = Deck::build().draw_pile(vec![1,2,3]).discard_pile(vec![4]) .stop_on_discards(true).done(); let mut n = 0; for c in &dk{ n += c; } assert_eq!(n,6);
type Item = &'a C
The type of the elements being iterated over.
type IntoIter = Chain<Iter<'a, C>, Iter<'a, C>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, C> IntoIterator for &'a mut Deck<C>
[src]
impl<'a, C> IntoIterator for &'a mut Deck<C>
Tweaking cards
use card_deck::Deck; let mut dk = Deck::build().draw_pile(vec![1,2,3]).pre_shuffle(false).done(); { for c in &mut dk{ *c = *c +1; } } assert_eq!(dk.draw_1(),Some(2));