rgeometry/data/vector/
mul.rs

1use array_init::array_init;
2use num_traits::NumOps;
3use std::ops::Mul;
4
5use super::Vector;
6use super::VectorView;
7
8impl<T, const N: usize> Mul<T> for Vector<T, N>
9where
10  T: NumOps + Clone,
11{
12  type Output = Vector<T, N>;
13
14  fn mul(self: Vector<T, N>, other: T) -> Self::Output {
15    Vector(array_init(|i| self.0[i].clone() * other.clone()))
16  }
17}
18
19impl<T, const N: usize> Mul<T> for VectorView<'_, T, N>
20where
21  T: NumOps + Clone,
22{
23  type Output = Vector<T, N>;
24  fn mul(self, other: T) -> Vector<T, N> {
25    Vector(array_init(|i| self.0[i].clone() * other.clone()))
26  }
27}