From c733f78e06bd02f7498e93b391e0f6094d91786a Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 19 Aug 2014 00:57:08 +0100 Subject: [PATCH] Add a Point2D::add_size(&Size2D) method. --- src/point.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/point.rs b/src/point.rs index 75746b4..8d4213c 100644 --- a/src/point.rs +++ b/src/point.rs @@ -8,6 +8,7 @@ // except according to those terms. use length::Length; +use size::Size2D; use std::fmt; use std::num::Zero; @@ -45,6 +46,12 @@ impl> Add, Point2D> for Point2D { } } +impl> Point2D { + pub fn add_size(&self, other: &Size2D) -> Point2D { + Point2D { x: self.x + other.width, y: self.y + other.height } + } +} + impl> Sub, Point2D> for Point2D { fn sub(&self, other: &Point2D) -> Point2D { Point2D(self.x - other.x, self.y - other.y)