Skip to content

Instantly share code, notes, and snippets.

@MatejLach
Created July 30, 2014 15:22
Show Gist options
  • Save MatejLach/a78457e6347324479c72 to your computer and use it in GitHub Desktop.
Save MatejLach/a78457e6347324479c72 to your computer and use it in GitHub Desktop.
Showcases how ownership is moved about in Rust...
// You can only have a single owner to a particular memory space.
fn main() {
let x = box 5i; // create an owned pointer "x" to the value 5i using the "box" keyword
let y = x; // "y" now owns 5i
println!("{}", x); // ERROR: "x" is no longer the owner 5i's memory space
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment