Implement Sub between two Vectors

This commit is contained in:
Hanno Braun 2025-01-09 18:33:24 +01:00
parent 7958712869
commit a2cc0f7699

View File

@ -101,3 +101,23 @@ where
Self { components }
}
}
impl<V, const D: usize> ops::Sub<V> for Vector<D>
where
V: Into<Vector<D>>,
{
type Output = Self;
fn sub(self, other: V) -> Self::Output {
let other = other.into();
let components = self
.components
.into_iter_fixed()
.zip(other.components)
.map(|(a, b)| a - b)
.collect();
Self { components }
}
}