rgeometry/data/vector/sub.rs
1use array_init::array_init;
2use std::ops::Index;
3use std::ops::Sub;
4
5use super::Vector;
6
7impl<'a, 'b, T, const N: usize> Sub<&'a Vector<T, N>> for &'b Vector<T, N>
8where
9 T: Sub<T, Output = T> + Clone,
10{
11 type Output = Vector<T, N>;
12
13 fn sub(self: &'b Vector<T, N>, other: &'a Vector<T, N>) -> Self::Output {
14 Vector(array_init(|i| {
15 self.0.index(i).clone() - other.0.index(i).clone()
16 }))
17 }
18}