Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
Created September 26, 2013 00:30
Show Gist options
  • Select an option

  • Save SiegeLord/6708208 to your computer and use it in GitHub Desktop.

Select an option

Save SiegeLord/6708208 to your computer and use it in GitHub Desktop.
Properties
struct A
{
x: int
}
struct B<'self>
{
a: &'self mut A
}
impl<'self> A
{
fn x(&'self mut self) -> B<'self>
{
B{a: self}
}
}
impl<'self> B<'self>
{
fn set(&'self mut self, x: int)
{
self.a.x = x;
}
}
fn main()
{
let mut a = A{x: 0};
a.x().set(2);
println!("{}", a.x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment