Implement scalar multiplication for Vector
This commit is contained in:
parent
980ac6c2a4
commit
345f0e1336
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user