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
#[derive(Debug)]
pub enum Direction {
UP,
DOWN,
LEFT,
RIGHT,
}
impl Direction {
pub fn value(&self) -> i16 {
match self {
Direction::UP => -1,
Direction::DOWN => 1,
Direction::LEFT => -1,
Direction::RIGHT => 1,
}
}
pub fn flip(&self) -> Self {
match self {
Direction::UP => Direction::DOWN,
Direction::DOWN => Direction::UP,
Direction::LEFT => Direction::RIGHT,
Direction::RIGHT => Direction::LEFT,
}
}
}