librustc: Make overloaded operators with explicit self translate correctly

This commit is contained in:
Patrick Walton 2012-11-27 14:12:33 -08:00
parent 082a88e42c
commit ca6970a65e
5 changed files with 56 additions and 2 deletions

View file

@ -0,0 +1,16 @@
struct S {
x: int
}
impl S {
pure fn add(&self, other: &S) -> S {
S { x: self.x + other.x }
}
}
fn main() {
let mut s = S { x: 1 };
s += S { x: 2 };
assert s.x == 3;
}