Implement division operation for Rectangle, Size and Vector

This commit is contained in:
Andy Terra 2025-01-29 18:32:37 -05:00 committed by Héctor Ramón Jiménez
parent 5195a59e20
commit 6f9b7a9005
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 54 additions and 0 deletions

View file

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