tree: implement pointer constraints
This commit is contained in:
parent
d4c4497043
commit
38d1267ec9
19 changed files with 707 additions and 4 deletions
18
src/fixed.rs
18
src/fixed.rs
|
|
@ -9,6 +9,8 @@ use std::{
|
|||
pub struct Fixed(pub i32);
|
||||
|
||||
impl Fixed {
|
||||
pub const EPSILON: Self = Fixed(1);
|
||||
|
||||
pub fn is_integer(self) -> bool {
|
||||
self.0 & 255 == 0
|
||||
}
|
||||
|
|
@ -86,6 +88,22 @@ impl Add for Fixed {
|
|||
}
|
||||
}
|
||||
|
||||
impl Sub<i32> for Fixed {
|
||||
type Output = Self;
|
||||
|
||||
fn sub(self, rhs: i32) -> Self::Output {
|
||||
Self(self.0 - (rhs << 8))
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<i32> for Fixed {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: i32) -> Self::Output {
|
||||
Self(self.0 + (rhs << 8))
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for Fixed {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
self.0 += rhs.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue