Skip to content

Commit ae1e2e4

Browse files
committed
feat(direction): init, Direction4, turn_{left,right}
1 parent 2b7a398 commit ae1e2e4

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/direction.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
pub enum Direction4 {
2+
Up,
3+
Right,
4+
Down,
5+
Left,
6+
}
7+
8+
impl Direction4 {
9+
pub fn turn_right(self) -> Self {
10+
match self {
11+
Self::Up => Self::Right,
12+
Self::Right => Self::Down,
13+
Self::Down => Self::Left,
14+
Self::Left => Self::Up,
15+
}
16+
}
17+
18+
pub fn turn_left(self) -> Self {
19+
match self {
20+
Self::Up => Self::Left,
21+
Self::Left => Self::Down,
22+
Self::Down => Self::Right,
23+
Self::Right => Self::Up,
24+
}
25+
}
26+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[macro_use]
22
pub mod parse;
3+
pub mod direction;
34
pub mod map;
45
pub mod points;

0 commit comments

Comments
 (0)