mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 04:06:48 +01:00
constify and deinline some methods
This commit is contained in:
parent
4279503681
commit
18a01b8355
10 changed files with 124 additions and 92 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue