use super::*; /// A numeric type that can be used as coordinate. /// /// FIXME: Replace with `num` crate? /// FIXME: Use AsRef/AsMut? /// /// ``` /// use tengri::draw::Coord; /// let a: u16 = Coord::zero(); /// let b: u16 = a.plus(1); /// let c: u16 = a.minus(2); /// let d = a.atomic(); /// ``` pub trait Coord: Send + Sync + Copy + Add + Sub + Mul + Div + Ord + PartialEq + Eq + Debug + Display + Default + From + Into + Into + Into + std::iter::Step { /// Zero in own type. fn zero () -> Self { 0.into() } /// Addition. fn plus (self, other: Self) -> Self; /// Saturating subtraction. fn minus (self, other: Self) -> Self { if self >= other { self - other } else { 0.into() } } /// Convert to [AtomicUsize]. fn atomic (self) -> AtomicUsize { AtomicUsize::new(self.into()) } }