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
use crate::Vec3;
use core::ops::MulAssign;

impl <T> MulAssign for Vec3<T> where T: MulAssign<T> + Copy {
    /// ```
    /// use gfxmath_vec3::Vec3;
    /// 
    /// let mut a = Vec3::<f32>::new(1.5, 2.5, -2.0);
    /// let b = Vec3::<f32>::new(4.0, 2.0,  4.0);
    /// a *= b;
    /// 
    /// assert_eq!( 6.0, a.x);
    /// assert_eq!( 5.0, a.y);
    /// assert_eq!(-8.0, a.z);
    /// 
    /// ```
    #[inline]
    fn mul_assign(&mut self, rhs: Self) {
        let l = self.as_mut_slice();
        let r = rhs.as_slice();

        l[0] *= r[0];
        l[1] *= r[1];
        l[2] *= r[2];
    }
}


impl <T> MulAssign<&Self> for Vec3<T> where T: MulAssign<T> + Copy {
    /// ```
    /// use gfxmath_vec3::Vec3;
    /// 
    /// let mut a = Vec3::<f32>::new(1.5, 2.5, -2.0);
    /// let b = Vec3::<f32>::new(4.0, 2.0,  4.0);
    /// a *= &b;
    /// 
    /// assert_eq!( 6.0, a.x);
    /// assert_eq!( 5.0, a.y);
    /// assert_eq!(-8.0, a.z);
    /// ```
    #[inline]
    fn mul_assign(&mut self, rhs: &Self) {
        let l = self.as_mut_slice();
        let r = rhs.as_slice();

        l[0] *= r[0];
        l[1] *= r[1];
        l[2] *= r[2];
    }
}