gridmap 0.0.2

library for handling infinite multi-dimensional grids of cells
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Mirror indexes

use super::Transform;

/// Mirror the index
pub struct Mirror<const D: usize>(pub [bool; D]);

/// Apply the transformation to the given index
impl<const D: usize> Transform<D> for Mirror<D> {
    fn apply(&self, index: &mut [isize; D]) {
        // flip the indexes
        for (d, i) in index.iter_mut().enumerate() {
            *i = if self.0[d] { -*i } else { *i };
        }
    }
}