Implement *Assign traits for Point

This commit is contained in:
edwloef 2025-11-30 11:20:18 +01:00
parent 17d070a816
commit 9a13c460e8
No known key found for this signature in database

View file

@ -74,6 +74,16 @@ where
}
}
impl<T> std::ops::AddAssign<Vector<T>> for Point<T>
where
T: std::ops::AddAssign,
{
fn add_assign(&mut self, vector: Vector<T>) {
self.x += vector.x;
self.y += vector.y;
}
}
impl<T> std::ops::Sub<Vector<T>> for Point<T>
where
T: std::ops::Sub<Output = T>,
@ -88,6 +98,16 @@ where
}
}
impl<T> std::ops::SubAssign<Vector<T>> for Point<T>
where
T: std::ops::SubAssign,
{
fn sub_assign(&mut self, vector: Vector<T>) {
self.x -= vector.x;
self.y -= vector.y;
}
}
impl<T> std::ops::Sub<Point<T>> for Point<T>
where
T: std::ops::Sub<Output = T>,