use std::marker::PhantomData; pub trait CoordinateSpace {} pub trait Coordinates { fn x(&self) -> T; fn y(&self) -> T; fn new(x: T, y: T) -> Self; const MAX: T; const MIN: T; } #[derive(PartialEq, Debug, Copy, Clone)] pub struct Virtual {} impl CoordinateSpace for Virtual {} #[derive(PartialEq, Debug, Copy, Clone)] pub struct Physical {} impl CoordinateSpace for Physical {} #[derive(PartialEq, Debug, Copy, Clone)] pub struct Coord8 { x: u8, y: u8, space: PhantomData } pub type VirtualCoordinates = Coord8; pub type PhysicalCoordinates = Coord8; impl Coordinates for Coord8 where S: CoordinateSpace { fn new(x: u8, y: u8) -> Self { Self { x: x, y: y, space: PhantomData } } fn x(&self) -> u8 { self.x } fn y(&self) -> u8 { self.y } const MAX: u8 = 255; const MIN: u8 = 255; }