1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::card::Card;

pub mod cards;
pub mod split;

pub use self::cards::Cards;
pub use self::split::{Segment, SegmentMut, Split};

pub trait Pile {
    fn cards(&self) -> &[Card];
    fn len(&self) -> usize;
    fn is_empty(&self) -> bool;
}

pub trait PileMut: Pile {
    fn take_at_most(&mut self, count: usize) -> Cards;
    fn take_at_most_one(&mut self) -> Option<Card>;
    fn take_or_none(&mut self, count: usize) -> Option<Cards>;

    fn take_exactly(&mut self, count: usize) -> Cards;
    fn take_exactly_one(&mut self) -> Card;

    fn take_all(&mut self) -> Cards;

    fn place<I>(&mut self, cards: I)
    where
        I: IntoIterator<Item = Card>;
    fn place_one(&mut self, card: Card);
}