Created
September 26, 2013 00:30
-
-
Save SiegeLord/6708208 to your computer and use it in GitHub Desktop.
Properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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