Implement scalar multiplication for Vector
This commit is contained in:
parent
980ac6c2a4
commit
345f0e1336
1 changed files with 11 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue