1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
use core::ops::DivAssign; use crate::Vec2; /// /// ``` /// use gfxmath_vec2::Vec2; /// /// let mut v1 = Vec2::new(1.0, 3.0); /// let v2 = Vec2::new(2.0, 5.0); /// v1 /= v2; /// /// assert_eq!(0.5, v1.x); /// assert_eq!(0.6, v1.y); /// /// let mut v1 = Vec2::new(9.0, 5.0); /// let v2 = Vec2::new(2.5, 2.0); /// /// *(&mut v1) /= v2; /// /// assert_eq!(3.6, v1.x); /// assert_eq!(2.5, v1.y); /// ``` #[opimps::impl_ops_assign(DivAssign)] #[inline] fn div_assign<T>(self: Vec2<T>, rhs: Vec2<T>) where T: DivAssign<T> + Copy { self.x /= rhs.x; self.y /= rhs.y; } /// /// ``` /// use gfxmath_vec2::Vec2; /// /// let mut v1 = Vec2::new(1.0, 3.0); /// let v2 = (2.0, 5.0); /// v1 /= v2; /// /// assert_eq!(0.5, v1.x); /// assert_eq!(0.6, v1.y); /// /// let mut v1 = Vec2::new(9.0, 5.0); /// let v2 = (2.5, 2.0); /// /// *(&mut v1) /= v2; /// /// assert_eq!(3.6, v1.x); /// assert_eq!(2.5, v1.y); /// ``` impl <T> DivAssign<(T, T)> for Vec2<T> where T: DivAssign { #[inline] fn div_assign(&mut self, rhs: (T, T)) { self.x /= rhs.0; self.y /= rhs.1; } } /// /// ``` /// use gfxmath_vec2::Vec2; /// /// let mut v1 = Vec2::new(9.0, 5.0); /// /// v1 /= 2.0; /// /// assert_eq!(4.5, v1.x); /// assert_eq!(2.5, v1.y); /// ``` #[opimps::impl_op_assign(DivAssign)] #[inline] fn div_assign<T>(self: Vec2<T>, rhs: T) where T: DivAssign<T> + Copy { self.x /= rhs; self.y /= rhs; }