Implement scalar multiplication for Vector

This commit is contained in:
Héctor Ramón Jiménez 2020-05-01 04:32:56 +02:00
parent 980ac6c2a4
commit 345f0e1336

View File

@ -43,6 +43,17 @@ where
}
}
impl<T> std::ops::Mul<T> for Vector<T>
where
T: std::ops::Mul<Output = T> + Copy,
{
type Output = Self;
fn mul(self, scale: T) -> Self {
Self::new(self.x * scale, self.y * scale)
}
}
impl<T> Default for Vector<T>
where
T: Default,