adic_shape/shape/
direction.rs

1#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
2/// The four cardinal directions
3pub enum Direction {
4    /// Up direction
5    Up,
6    /// Down direction
7    Down,
8    /// Left direction
9    Left,
10    /// Right direction
11    Right,
12}
13
14impl Direction {
15    #[must_use]
16    /// Return opposite direction
17    pub fn opposite(&self) -> Self {
18        match self {
19            Self::Up => Self::Down,
20            Self::Down => Self::Up,
21            Self::Left => Self::Right,
22            Self::Right => Self::Left,
23        }
24    }
25    #[must_use]
26    /// Return counterclockwise direction
27    pub fn ccwise(&self) -> Self {
28        match self {
29            Self::Up => Self::Left,
30            Self::Down => Self::Right,
31            Self::Left => Self::Down,
32            Self::Right => Self::Up,
33        }
34    }
35    #[must_use]
36    /// Return clockwise direction
37    pub fn cwise(&self) -> Self {
38        match self {
39            Self::Up => Self::Right,
40            Self::Down => Self::Left,
41            Self::Left => Self::Up,
42            Self::Right => Self::Down,
43        }
44    }
45}
46
47// TODO: Add double-direction, single/double-direction, and multi-direction