Skip to content

Commit

Permalink
✨ Horizontal and Vertical enums
Browse files Browse the repository at this point in the history
  • Loading branch information
tguichaoua committed Dec 21, 2024
1 parent 108cf2e commit 4b0f32f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ pub enum Dir {
Left,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Horizontal {
Left,
Right,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Vertical {
Up,
Down,
}

#[allow(non_upper_case_globals)]
impl Dir {
pub const North: Dir = Dir::Up;
Expand Down Expand Up @@ -221,6 +233,24 @@ impl Dir {
}
}

impl From<Horizontal> for Dir {
fn from(value: Horizontal) -> Self {
match value {
Horizontal::Left => Dir::Left,
Horizontal::Right => Dir::Right,
}
}
}

impl From<Vertical> for Dir {
fn from(value: Vertical) -> Self {
match value {
Vertical::Up => Dir::Up,
Vertical::Down => Dir::Down,
}
}
}

/* -------------------------------------------------------------------------- */

#[inline]
Expand Down

0 comments on commit 4b0f32f

Please sign in to comment.