constify and deinline some methods

This commit is contained in:
🪞👃🪞 2025-04-13 21:11:07 +03:00
parent 4279503681
commit 18a01b8355
10 changed files with 124 additions and 92 deletions

View file

@ -1,12 +1,6 @@
use std::fmt::{Debug, Display};
use std::ops::{Add, Sub, Mul, Div};
impl Coordinate for u16 {
#[inline] fn plus (self, other: Self) -> Self {
self.saturating_add(other)
}
}
/// A linear coordinate.
pub trait Coordinate: Send + Sync + Copy
+ Add<Self, Output=Self>
@ -19,13 +13,19 @@ pub trait Coordinate: Send + Sync + Copy
+ Into<usize>
+ Into<f64>
{
#[inline] fn zero () -> Self { 0.into() }
#[inline] fn minus (self, other: Self) -> Self {
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()
}
}
fn plus (self, other: Self) -> Self;
}
impl Coordinate for u16 {
fn plus (self, other: Self) -> Self {
self.saturating_add(other)
}
}