1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/// A trait for types describing a position pub trait Position<T> { /// Get the x coordinate fn x(&self) -> T; /// Get the y coordinate fn y(&self) -> T; } impl<T: Copy> Position<T> for (T, T) { fn x(&self) -> T { self.0 } fn y(&self) -> T { self.1 } }