rustc: Implement "deriving" for monomorphic structs via a syntax extension. r=brson

This commit is contained in:
Patrick Walton 2012-11-19 18:05:50 -08:00
parent 8f22582e9f
commit a7aecc46a5
6 changed files with 450 additions and 0 deletions

View file

@ -0,0 +1,16 @@
#[deriving_eq]
enum Foo {
Bar,
Baz,
Boo
}
fn main() {
let a = Bar;
let b = Bar;
assert a == b;
assert !(a != b);
assert a.eq(&b);
assert !a.ne(&b);
}

View file

@ -0,0 +1,16 @@
#[deriving_eq]
struct Foo {
x: int,
y: int,
z: int,
}
fn main() {
let a = Foo { x: 1, y: 2, z: 3 };
let b = Foo { x: 1, y: 2, z: 3 };
assert a == b;
assert !(a != b);
assert a.eq(&b);
assert !a.ne(&b);
}