gfxmath_vec4/impls/mul/
mulassign.rs

1use crate::Vec4;
2use core::ops::MulAssign;
3
4/// ```
5/// use gfxmath_vec4::Vec4;
6/// 
7/// let mut a = Vec4::<f32>::new(1.5, 2.5, -2.0, 3.0);
8/// let b = Vec4::<f32>::new(4.0, 2.0,  4.0, 4.0);
9/// a *= b;
10/// 
11/// assert_eq!( 6.0, a.x);
12/// assert_eq!( 5.0, a.y);
13/// assert_eq!(-8.0, a.z);
14/// assert_eq!(12.0, a.w);
15/// 
16/// ```
17#[opimps::impl_ops_assign(MulAssign)]
18#[inline]
19fn mul_assign<T>(self: Vec4<T>, rhs: Vec4<T>) where T: MulAssign<T> + Copy {
20    let l = self.as_mut_slice();
21    let r = rhs.as_slice();
22
23    l[0] *= r[0];
24    l[1] *= r[1];
25    l[2] *= r[2];
26    l[3] *= r[3];
27}
28
29/// ```
30/// use gfxmath_vec4::Vec4;
31/// 
32/// let mut a = Vec4::<f32>::new(1.5, 2.5, -2.0, 9.0);
33/// a *= 2.0;
34/// 
35/// assert_eq!( 3.0, a.x);
36/// assert_eq!( 5.0, a.y);
37/// assert_eq!(-4.0, a.z);
38/// assert_eq!(18.0, a.w); 
39/// ```
40#[opimps::impl_op_assign(MulAssign)]
41#[inline]
42fn mul_assign<T>(self: Vec4<T>, rhs: T) where T: MulAssign<T> + Copy {
43    let l = self.as_mut_slice();
44
45    l[0] *= rhs;
46    l[1] *= rhs;
47    l[2] *= rhs;
48    l[3] *= rhs;
49}