2 // Test that we can overload the `+` operator for points so that two
3 // points can be added, and a point can be added to an integer.
7 #[derive(Debug,PartialEq,Eq)]
13 impl ops::Add for Point {
16 fn add(self, other: Point) -> Point {
17 Point {x: self.x + other.x, y: self.y + other.y}
21 impl ops::Add<isize> for Point {
24 fn add(self, other: isize) -> Point {
25 Point {x: self.x + other,
31 let mut p = Point {x: 10, y: 20};
32 p = p + Point {x: 101, y: 102};
33 assert_eq!(p, Point {x: 111, y: 122});
35 assert_eq!(p, Point {x: 112, y: 123});