Skip to content

Instantly share code, notes, and snippets.

@wycats
Created January 31, 2014 17:56
Show Gist options
  • Save wycats/8738699 to your computer and use it in GitHub Desktop.
Save wycats/8738699 to your computer and use it in GitHub Desktop.
struct Foo {
bar: ~Bar
}
struct Bar {
age: int
}
impl IndexMut<int,Bar> for Foo {
fn index_mut<'a>(&'a mut self, element: &int) -> &'a mut Bar {
&mut *self.bar
}
}
fn main() {
let foo = &mut Foo{ bar: ~Bar{ age: 10 } };
let bar: &mut Bar = &mut foo[10];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment