1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
use std::fmt;
use crate::geometry::Direction;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Command {
Move(u32, u32),
Dig(u32, u32),
Shoot(Direction),
DoNothing,
}
impl fmt::Display for Command {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Command::*;
match self {
Move(x, y) => write!(f, "move {} {}", x, y),
Dig(x, y) => write!(f, "dig {} {}", x, y),
Shoot(dir) => write!(f, "shoot {}", dir),
DoNothing => write!(f, "nothing"),
}
}
}
|