From e862a86fe6ac2d840c3165ca9571849a3e5545f5 Mon Sep 17 00:00:00 2001 From: wires Date: Tue, 27 May 2025 22:22:32 -0400 Subject: [PATCH] += and /= for vectors --- core/src/geometry.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/geometry.rs b/core/src/geometry.rs index 599474b..d4a5208 100644 --- a/core/src/geometry.rs +++ b/core/src/geometry.rs @@ -1,6 +1,6 @@ use std::{ fmt, - ops::{Add, Deref, Div, Mul, Sub}, + ops::{Add, AddAssign, Deref, Div, DivAssign, Mul, Sub}, }; pub mod shapes; @@ -94,6 +94,12 @@ impl Div for Vector { } } +impl DivAssign for Vector { + fn div_assign(&mut self, rhs: f32) { + *self = *self / rhs; + } +} + impl Add for Vector { type Output = Self; @@ -102,6 +108,12 @@ impl Add for Vector { } } +impl AddAssign for Vector { + fn add_assign(&mut self, rhs: Self) { + *self = *self + rhs; + } +} + #[repr(transparent)] #[derive(Clone, Copy)] pub struct Point(glam::Vec3A);