Skip to main content

steel_utils/
axis.rs

1/// An axis in 3D space.
2#[derive(Copy, Clone, Debug, Eq)]
3#[derive_const(PartialEq)]
4#[expect(missing_docs, reason = "variant names are self-explanatory")]
5pub enum Axis {
6    X,
7    Y,
8    Z,
9}
10
11#[expect(missing_docs, reason = "method names are self-explanatory")]
12impl Axis {
13    #[must_use]
14    pub const fn is_horizontal(self) -> bool {
15        matches!(self, Axis::X | Axis::Z)
16    }
17
18    #[must_use]
19    pub const fn is_vertical(self) -> bool {
20        matches!(self, Axis::Y)
21    }
22
23    #[must_use]
24    pub const fn as_str(&self) -> &str {
25        match self {
26            Axis::X => "x",
27            Axis::Y => "y",
28            Axis::Z => "z",
29        }
30    }
31}