3 #![allow(unused_variables)]
7 #[derive(Copy, Clone, Debug)]
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::Sub for Point {
24 fn sub(self, other: Point) -> Point {
25 Point {x: self.x - other.x, y: self.y - other.y}
29 impl ops::Neg for Point {
32 fn neg(self) -> Point {
33 Point {x: -self.x, y: -self.y}
37 impl ops::Not for Point {
40 fn not(self) -> Point {
41 Point {x: !self.x, y: !self.y }
45 impl ops::Index<bool> for Point {
48 fn index(&self, x: bool) -> &isize {
57 impl cmp::PartialEq for Point {
58 fn eq(&self, other: &Point) -> bool {
59 (*self).x == (*other).x && (*self).y == (*other).y
61 fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
65 let mut p = Point {x: 10, y: 20};
66 p = p + Point {x: 101, y: 102};
67 p = p - Point {x: 100, y: 100};
68 assert_eq!(p + Point {x: 5, y: 5}, Point {x: 16, y: 27});
69 assert_eq!(-p, Point {x: -11, y: -22});
70 assert_eq!(p[true], 11);
71 assert_eq!(p[false], 22);
74 assert_eq!(q.x, !(p.x));
75 assert_eq!(q.y, !(p.y));
81 fn result(i: isize) { }