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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use super::Zone;
use crate::card::Card;
use crate::piles::{Cards, Pile as _};
pub mod draw;
pub mod replace;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Stock {
pile: Cards,
}
#[derive(Debug, Clone, Copy)]
pub struct View<'a> {
pub stack: &'a [Card],
}
impl From<Cards> for Stock {
fn from(pile: Cards) -> Self {
Self { pile }
}
}
impl FromIterator<Card> for Stock {
fn from_iter<I>(cards: I) -> Self
where
I: IntoIterator<Item = Card>,
{
cards.into_iter().collect::<Cards>().into()
}
}
impl Zone for Stock {
type View<'a> = View<'a>
where
Self: 'a;
fn as_view(&self) -> Self::View<'_> {
View {
stack: self.pile.cards(),
}
}
}