// Test overloaded indexing combined with autoderef.
+#![allow(unknown_features)]
+#![feature(box_syntax)]
+
+use std::ops::{Index, IndexMut};
+
struct Foo {
x: int,
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
}
}
-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
assert_eq!(f[1].get(), 5);
assert_eq!(f[1].get_from_ref(), 5);
}
-