From a0a7610bc1381b5c26c1677bb7679d022b168499 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 26 Oct 2023 19:31:13 +0200 Subject: feat(engine): add Vec3 AddAssign & SubAssign impls --- engine/src/vector.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'engine') 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 @@ -163,3 +163,27 @@ where self } } + +impl AddAssign for Vec3 +where + Value: AddAssign, +{ + fn add_assign(&mut self, rhs: Self) + { + self.x += rhs.x; + self.y += rhs.y; + self.z += rhs.z; + } +} + +impl SubAssign for Vec3 +where + Value: SubAssign, +{ + fn sub_assign(&mut self, rhs: Self) + { + self.x -= rhs.x; + self.y -= rhs.y; + self.z -= rhs.z; + } +} -- cgit v1.2.3-18-g5258