diff --git a/geometry/src/rect.rs b/geometry/src/rect.rs index 858c2712..1a449cd9 100644 --- a/geometry/src/rect.rs +++ b/geometry/src/rect.rs @@ -12,7 +12,7 @@ use crate::vector::{IntoVector2F, Vector2F, Vector2I}; use pathfinder_simd::default::{F32x4, I32x4}; -use std::ops::{Add, Mul, Sub}; +use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign}; #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct RectF(pub F32x4); @@ -198,6 +198,13 @@ impl Add for RectF { } } +impl AddAssign for RectF { + #[inline] + fn add_assign(&mut self, other: Vector2F) { + *self = *self + other + } +} + impl Add for RectF { type Output = RectF; #[inline] @@ -206,6 +213,13 @@ impl Add for RectF { } } +impl AddAssign for RectF { + #[inline] + fn add_assign(&mut self, other: f32) { + *self = *self + other + } +} + impl Mul for RectF { type Output = RectF; #[inline] @@ -214,6 +228,13 @@ impl Mul for RectF { } } +impl MulAssign for RectF { + #[inline] + fn mul_assign(&mut self, other: Vector2F) { + *self = *self * other + } +} + impl Mul for RectF { type Output = RectF; #[inline] @@ -222,6 +243,13 @@ impl Mul for RectF { } } +impl MulAssign for RectF { + #[inline] + fn mul_assign(&mut self, other: f32) { + *self = *self * other + } +} + impl Sub for RectF { type Output = RectF; #[inline] @@ -230,6 +258,13 @@ impl Sub for RectF { } } +impl SubAssign for RectF { + #[inline] + fn sub_assign(&mut self, other: Vector2F) { + *self = *self - other + } +} + impl Sub for RectF { type Output = RectF; #[inline] @@ -238,6 +273,13 @@ impl Sub for RectF { } } +impl SubAssign for RectF { + #[inline] + fn sub_assign(&mut self, other: f32) { + *self = *self - other + } +} + /// NB: The origin is inclusive, while the lower right point is exclusive. #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct RectI(pub I32x4);