Created
July 30, 2014 15:22
-
-
Save MatejLach/a78457e6347324479c72 to your computer and use it in GitHub Desktop.
Showcases how ownership is moved about in Rust...
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
// 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