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
44
use super::Zone;
use crate::card::Card;
use crate::piles::Split;
pub mod empty;
pub mod place;
pub mod take;
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Waste {
pile: Split,
}
#[derive(Debug, Clone, Copy)]
pub struct View<'a> {
pub stack: &'a [Card],
pub fan: &'a [Card],
}
impl Waste {
pub const fn empty() -> Self {
Self {
pile: Split::empty(),
}
}
}
impl From<Split> for Waste {
fn from(pile: Split) -> Self {
Self { pile }
}
}
impl Zone for Waste {
type View<'a> = View<'a>
where
Self: 'a;
fn as_view(&self) -> Self::View<'_> {
let (stack, fan) = self.pile.cards_split();
View { stack, fan }
}
}