Skip to content

Commit

Permalink
Merge pull request #56 from servo/point+size
Browse files Browse the repository at this point in the history
Implement `Point2D + Size2D -> Point2D`, now that we have multi-dispatch
  • Loading branch information
mbrubeck committed Nov 25, 2014
2 parents c231080 + 1df99b1 commit 95e7461
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl<T:Clone + Add<T,T>> Add<Point2D<T>, Point2D<T>> for Point2D<T> {
}
}

impl<T:Clone + Add<T,T>> Add<Size2D<T>, Point2D<T>> for Point2D<T> {
fn add(&self, other: &Size2D<T>) -> Point2D<T> {
Point2D(self.x + other.width, self.y + other.height)
}
}

impl<T: Add<T, T>> Point2D<T> {
pub fn add_size(&self, other: &Size2D<T>) -> Point2D<T> {
Point2D { x: self.x + other.width, y: self.y + other.height }
Expand Down

0 comments on commit 95e7461

Please sign in to comment.