mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
28 lines
621 B
Rust
28 lines
621 B
Rust
use std::fmt::{Debug, Display};
|
|
use std::ops::{Add, Sub, Mul, Div};
|
|
|
|
impl Coordinate for u16 {}
|
|
|
|
/// A linear coordinate.
|
|
pub trait Coordinate: Send + Sync + Copy
|
|
+ Add<Self, Output=Self>
|
|
+ Sub<Self, Output=Self>
|
|
+ Mul<Self, Output=Self>
|
|
+ Div<Self, Output=Self>
|
|
+ Ord + PartialEq + Eq
|
|
+ Debug + Display + Default
|
|
+ From<u16> + Into<u16>
|
|
+ Into<usize>
|
|
+ Into<f64>
|
|
{
|
|
#[inline] fn minus (self, other: Self) -> Self {
|
|
if self >= other {
|
|
self - other
|
|
} else {
|
|
0.into()
|
|
}
|
|
}
|
|
#[inline] fn zero () -> Self {
|
|
0.into()
|
|
}
|
|
}
|