]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/overloaded-index-autoderef.rs
make `IndexMut` a super trait over `Index`
[rust.git] / src / test / run-pass / overloaded-index-autoderef.rs
index dcb0c40c6088a95eecc651f32359efe8839ada78..d5ccf8cd2befb0f4f18e29fc0021ba49f4d814bf 100644 (file)
@@ -10,6 +10,9 @@
 
 // Test overloaded indexing combined with autoderef.
 
+#![allow(unknown_features)]
+#![feature(box_syntax)]
+
 use std::ops::{Index, IndexMut};
 
 struct Foo {
@@ -17,7 +20,9 @@ struct Foo {
     y: int,
 }
 
-impl Index<int,int> for Foo {
+impl Index<int> for Foo {
+    type Output = int;
+
     fn index(&self, z: &int) -> &int {
         if *z == 0 {
             &self.x
@@ -27,7 +32,7 @@ fn index(&self, z: &int) -> &int {
     }
 }
 
-impl IndexMut<int,int> for Foo {
+impl IndexMut<int> for Foo {
     fn index_mut(&mut self, z: &int) -> &mut int {
         if *z == 0 {
             &mut self.x
@@ -78,4 +83,3 @@ fn main() {
     assert_eq!(f[1].get(), 5);
     assert_eq!(f[1].get_from_ref(), 5);
 }
-