// Test that we still see borrowck errors of various kinds when using
// indexing and autoderef in combination.
-#![feature(associated_types)]
-
use std::ops::{Index, IndexMut};
struct Foo {
- x: int,
- y: int,
+ x: isize,
+ y: isize,
}
impl Index<String> for Foo {
- type Output = int;
+ type Output = isize;
- fn index<'a>(&'a self, z: &String) -> &'a int {
- if z.as_slice() == "x" {
+ fn index<'a>(&'a self, z: &String) -> &'a isize {
+ if *z == "x" {
&self.x
} else {
&self.y
}
impl IndexMut<String> for Foo {
- type Output = int;
-
- fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut int {
- if z.as_slice() == "x" {
+ fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut isize {
+ if *z == "x" {
&mut self.x
} else {
&mut self.y
fn main() {
}
-
-