diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/rectangle.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs index b9d0d5d2..87046df4 100644 --- a/core/src/rectangle.rs +++ b/core/src/rectangle.rs @@ -1,4 +1,4 @@ -use crate::{Point, Size}; +use crate::{Point, Size, Vector}; /// A rectangle. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] @@ -140,3 +140,18 @@ impl From<Rectangle<f32>> for Rectangle<u32> { } } } + +impl<T> std::ops::Add<Vector<T>> for Rectangle<T> +where + T: std::ops::Add<Output = T>, +{ + type Output = Rectangle<T>; + + fn add(self, translation: Vector<T>) -> Self { + Rectangle { + x: self.x + translation.x, + y: self.y + translation.y, + ..self + } + } +} |