pub trait GridPos<const DIMS: usize>: Copy + Debug + Default + Eq + Sized {
type Coord: Int;
// Required methods
fn to_array(self) -> [Self::Coord; DIMS];
fn from_array(array: [Self::Coord; DIMS]) -> Self;
// Provided methods
fn map<MapFn, Output>(self, map_fn: MapFn) -> [Output; DIMS]
where MapFn: FnMut(Self::Coord) -> Output { ... }
fn to_native(self, start: Self) -> Option<Self> { ... }
fn native_to_index(self, size: Self) -> Option<isize> { ... }
fn from_native(native: Self, start: Self) -> Option<Self> { ... }
}
Expand description
Trait for values to use as indices for a GridView
.
For example, a two dimensional grid might be indexed with a struct containing an x
and a y
coordinate.
This trait provides methods to translate whatever coordinate system is in use to and from a
single usize
value.