Skip to content

Instantly share code, notes, and snippets.

@matthewphilyaw
Created March 15, 2014 15:01
Show Gist options
  • Select an option

  • Save matthewphilyaw/9568628 to your computer and use it in GitHub Desktop.

Select an option

Save matthewphilyaw/9568628 to your computer and use it in GitHub Desktop.
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()));
}
@matthewphilyaw
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment