Implement Primitive::Cached
This commit is contained in:
parent
37f0d97159
commit
b74e7e7353
12 changed files with 151 additions and 105 deletions
|
|
@ -46,3 +46,14 @@ impl std::ops::Add<Vector> for Point {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Sub<Vector> for Point {
|
||||
type Output = Self;
|
||||
|
||||
fn sub(self, vector: Vector) -> Self {
|
||||
Self {
|
||||
x: self.x - vector.x,
|
||||
y: self.y - vector.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,17 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::Sub for Vector<T>
|
||||
where
|
||||
T: std::ops::Sub<Output = T>,
|
||||
{
|
||||
type Output = Self;
|
||||
|
||||
fn sub(self, b: Self) -> Self {
|
||||
Self::new(self.x - b.x, self.y - b.y)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for Vector<T>
|
||||
where
|
||||
T: Default,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue