Created
March 15, 2014 15:01
-
-
Save matthewphilyaw/9568628 to your computer and use it in GitHub Desktop.
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
| extern mod extra; | |
| use extra::arc::Arc; | |
| fn main() { | |
| let x = ~5; | |
| let y = Arc::new(x); // x is no longer pointer to ~5, and y points to the pointer x was that is not to the value but the | |
| // but the pointer x held. | |
| let z = y.clone(); // same semantics, the clone produces a pointer to the pointer x was. | |
| println!("{}", **(y.get())); // see we have that double reference we have to deref twice. | |
| println!("{}", **(z.get())); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured out the double ref thing from the compiler in that y.get() complained about can't find default format implementation for &~int, adding one asterisk reported ~int, and double compiled.