diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-11-27 14:12:33 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-11-28 11:01:14 -0800 |
| commit | ca6970a65ebdc153d53e9b6c2ccb224ee705ac94 (patch) | |
| tree | 883d7bd463736587a47d4d86a559180960521c1c /src/test | |
| parent | 082a88e42cdefce78a8f1f869971bbabd74ebca2 (diff) | |
| download | rust-ca6970a65ebdc153d53e9b6c2ccb224ee705ac94.tar.gz rust-ca6970a65ebdc153d53e9b6c2ccb224ee705ac94.zip | |
librustc: Make overloaded operators with explicit self translate correctly
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/operator-overloading-explicit-self.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/run-pass/operator-overloading-explicit-self.rs b/src/test/run-pass/operator-overloading-explicit-self.rs new file mode 100644 index 00000000000..3b198078cf8 --- /dev/null +++ b/src/test/run-pass/operator-overloading-explicit-self.rs @@ -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; +} + |
