kd_tree_rs/
dim.rs

1#[derive(Debug, PartialEq)]
2pub enum Dim {
3    X,
4    Y,
5}
6
7impl Dim {
8    const DIMENSIONS: usize = 2;
9
10    pub(crate) fn from_depth(mut n: usize) -> Dim {
11        n = n.rem_euclid(Dim::DIMENSIONS);
12        assert!(n < Dim::DIMENSIONS);
13        match n {
14            0 => Dim::X,
15            1 => Dim::Y,
16            _ => panic!("Higher dimensions not implemented"),
17        }
18    }
19}