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
use super::Table;
use crate::zones::from_to::draw_or_replace::DrawCount;
use crate::zones::from_to::{self, FromTo};
use crate::{action, undo};
#[derive(Debug)]
pub struct Action;
#[derive(Debug)]
pub struct Value(from_to::draw_or_replace::Value);
impl action::Action for Action {
type State<'s> = &'s DrawCount;
type Value = Value;
type Error = !;
}
impl action::Target<Action> for Table {
fn update(&mut self, _: Action, state: &DrawCount) -> Result<Value, !> {
let mut target = FromTo(&mut self.stock, &mut self.waste);
let Ok(inner_value) = target.update(from_to::draw_or_replace::Action, state);
Ok(Value(inner_value))
}
}
impl undo::Target<Value> for Table {
fn revert(&mut self, Value(inner_value): Value) {
let mut target = FromTo(&mut self.stock, &mut self.waste);
target.revert(inner_value);
}
}