rustc: Add an "ne" method to the Eq trait, and implement it everywhere

This commit is contained in:
Patrick Walton 2012-09-07 12:06:02 -07:00
parent ac1f84c153
commit feb014eb3c
76 changed files with 218 additions and 60 deletions

View file

@ -46,13 +46,14 @@ impl an_enum : cmp::Eq {
pure fn eq(&&other: an_enum) -> bool {
self.v == other.v
}
pure fn ne(&&other: an_enum) -> bool { !self.eq(other) }
}
impl point : cmp::Eq {
pure fn eq(&&other: point) -> bool {
self.x == other.x &&
self.y == other.y
self.x == other.x && self.y == other.y
}
pure fn ne(&&other: point) -> bool { !self.eq(other) }
}
impl<T:cmp::Eq> quark<T> : cmp::Eq {
@ -68,6 +69,7 @@ impl<T:cmp::Eq> quark<T> : cmp::Eq {
}
}
}
pure fn ne(&&other: quark<T>) -> bool { !self.eq(other) }
}
@ -75,6 +77,7 @@ impl c_like : cmp::Eq {
pure fn eq(&&other: c_like) -> bool {
self as int == other as int
}
pure fn ne(&&other: c_like) -> bool { !self.eq(other) }
}
impl expr : cmp::Eq {
@ -100,6 +103,7 @@ impl expr : cmp::Eq {
}
}
}
pure fn ne(&&other: expr) -> bool { !self.eq(other) }
}
#[auto_serialize]
@ -109,6 +113,7 @@ impl<T:cmp::Eq> spanned<T> : cmp::Eq {
pure fn eq(&&other: spanned<T>) -> bool {
self.lo == other.lo && self.hi == other.hi && self.node.eq(other.node)
}
pure fn ne(&&other: spanned<T>) -> bool { !self.eq(other) }
}
#[auto_serialize]

View file

@ -93,6 +93,7 @@ impl p : cmp::Eq {
pure fn eq(&&other: p) -> bool {
self.x == other.x && self.y == other.y
}
pure fn ne(&&other: p) -> bool { !self.eq(other) }
}
fn test_class() {

View file

@ -7,6 +7,7 @@ impl cat_type : cmp::Eq {
pure fn eq(&&other: cat_type) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: cat_type) -> bool { !self.eq(other) }
}
// Very silly -- this just returns the value of the name field

View file

@ -2,5 +2,6 @@ fn main() {
enum x { foo }
impl x : core::cmp::Eq {
pure fn eq(&&other: x) -> bool { self as int == other as int }
pure fn ne(&&other: x) -> bool { !self.eq(other) }
}
}

View file

@ -5,6 +5,7 @@ impl foo : cmp::Eq {
pure fn eq(&&other: foo) -> bool {
self.a == other.a && self.b == other.b && self.c == other.c
}
pure fn ne(&&other: foo) -> bool { !self.eq(other) }
}
const x : foo = foo { a:1, b:2, c: 3 };

View file

@ -4,6 +4,7 @@ impl chan : cmp::Eq {
pure fn eq(&&other: chan) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: chan) -> bool { !self.eq(other) }
}
fn wrapper3(i: chan) {

View file

@ -12,6 +12,7 @@ mod foo {
pure fn eq(&&other: t) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: t) -> bool { !self.eq(other) }
}
fn f() -> t { return t1; }

View file

@ -14,6 +14,7 @@ impl mood : cmp::Eq {
pure fn eq(&&other: mood) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: mood) -> bool { !self.eq(other) }
}
fn test_tag() {

View file

@ -14,6 +14,7 @@ impl mood : cmp::Eq {
pure fn eq(&&other: mood) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: mood) -> bool { !self.eq(other) }
}
fn test_tag() {

View file

@ -12,6 +12,7 @@ mod pipes {
pure fn eq(&&other: state) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: state) -> bool { !self.eq(other) }
}
type packet<T: send> = {

View file

@ -31,6 +31,7 @@ impl Point : cmp::Eq {
pure fn eq(&&other: Point) -> bool {
self.x == other.x && self.y == other.y
}
pure fn ne(&&other: Point) -> bool { !self.eq(other) }
}
fn main() {

View file

@ -6,6 +6,7 @@ impl foo : cmp::Eq {
pure fn eq(&&other: foo) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: foo) -> bool { !self.eq(other) }
}
fn main() {

View file

@ -13,6 +13,7 @@ impl color : cmp::Eq {
pure fn eq(&&other: color) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: color) -> bool { !self.eq(other) }
}
fn main() {

View file

@ -71,6 +71,7 @@ impl t : cmp::Eq {
}
}
}
pure fn ne(&&other: t) -> bool { !self.eq(other) }
}
fn test_tag() {