use std::fmt::{Debug, Display}; use std::ops::{Add, Sub, Mul, Div}; /// A linear coordinate. pub trait Coordinate: Send + Sync + Copy + Add + Sub + Mul + Div + Ord + PartialEq + Eq + Debug + Display + Default + From + Into + Into + Into { fn zero () -> Self { 0.into() } fn plus (self, other: Self) -> Self; fn minus (self, other: Self) -> Self { if self >= other { self - other } else { 0.into() } } } impl Coordinate for u16 { fn plus (self, other: Self) -> Self { self.saturating_add(other) } }