1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::Point2;
use std::ops::Index;

#[derive(Copy, Clone, PartialEq, Eq)]
pub(crate) enum Axis {
    X = 0,
    Y = 1,
}

impl Index<Axis> for Point2 {
    type Output = f32;

    #[inline]
    fn index(&self, axis: Axis) -> &f32 {
        match axis {
            Axis::X => &self.x,
            Axis::Y => &self.y,
        }
    }
}