diff options
Diffstat (limited to 'engine/src/vector.rs')
-rw-r--r-- | engine/src/vector.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs index ab80aac..e8d51d2 100644 --- a/engine/src/vector.rs +++ b/engine/src/vector.rs @@ -1,4 +1,4 @@ -use std::ops::{Add, Mul, Neg, Sub}; +use std::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign}; #[derive(Debug)] pub struct Vec2<Value> @@ -163,3 +163,27 @@ where self } } + +impl<Value> AddAssign for Vec3<Value> +where + Value: AddAssign<Value>, +{ + fn add_assign(&mut self, rhs: Self) + { + self.x += rhs.x; + self.y += rhs.y; + self.z += rhs.z; + } +} + +impl<Value> SubAssign for Vec3<Value> +where + Value: SubAssign<Value>, +{ + fn sub_assign(&mut self, rhs: Self) + { + self.x -= rhs.x; + self.y -= rhs.y; + self.z -= rhs.z; + } +} |