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