1 use std::ops::{Index, IndexMut};
8 impl Index<String> for Foo {
11 fn index(&self, z: String) -> &isize {
20 impl IndexMut<String> for Foo {
21 fn index_mut(&mut self, z: String) -> &mut isize {
34 impl Index<isize> for Bar {
37 fn index<'a>(&'a self, z: isize) -> &'a isize {
47 let mut s = "hello".to_string();
51 //~^ ERROR cannot move out of `s` because it is borrowed
54 //~^ ERROR cannot move out of `s` because it is borrowed
55 //~| ERROR use of moved value: `s`
62 println!("{}", s[i]); // no error, i is copy
68 fn use_mut<T>(_: &mut T) { }