summary refs log tree commit diff
path: root/src/test/run-pass/operator-overloading.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-07-03 14:32:41 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-07-07 11:43:23 -0700
commit7e4e99123a68c92f684e5c4466101c1951e86895 (patch)
tree270c38b9308597595fc05b233e25ef8252628439 /src/test/run-pass/operator-overloading.rs
parent4f120e6bafe971452adfede158a7957b00562a4e (diff)
downloadrust-7e4e99123a68c92f684e5c4466101c1951e86895.tar.gz
rust-7e4e99123a68c92f684e5c4466101c1951e86895.zip
librustc (RFC #34): Implement the new `Index` and `IndexMut` traits.
This will break code that used the old `Index` trait. Change this code
to use the new `Index` traits. For reference, here are their signatures:

    pub trait Index<Index,Result> {
        fn index<'a>(&'a self, index: &Index) -> &'a Result;
    }
    pub trait IndexMut<Index,Result> {
        fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result;
    }

Closes #6515.

[breaking-change]
Diffstat (limited to 'src/test/run-pass/operator-overloading.rs')
-rw-r--r--src/test/run-pass/operator-overloading.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs
index 00e19b8481f..a36d8132b26 100644
--- a/src/test/run-pass/operator-overloading.rs
+++ b/src/test/run-pass/operator-overloading.rs
@@ -43,8 +43,12 @@ impl ops::Not<Point> for Point {
 }
 
 impl ops::Index<bool,int> for Point {
-    fn index(&self, x: &bool) -> int {
-        if *x { self.x } else { self.y }
+    fn index<'a>(&'a self, x: &bool) -> &'a int {
+        if *x {
+            &self.x
+        } else {
+            &self.y
+        }
     }
 }