Skip to content

Commit

Permalink
Implement Point2D + Size2D -> Point2D, now that we have multi-dispatch
Browse files Browse the repository at this point in the history
... in addition to the existing `Point2D + Point2D -> Point2D`.
  • Loading branch information
SimonSapin committed Nov 21, 2014
1 parent 6f750fc commit 1df99b1
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 1df99b1

Please sign in to comment.