Last active
April 27, 2016 20:30
-
-
Save bugaevc/e9f4db6a4819bc212dc08bad54528c3b to your computer and use it in GitHub Desktop.
This file contains 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
fn print_sum(a: i32, b: i32) { | |
println!("{}", a + b); | |
// the copied a and b are dropped and deallocated here | |
} | |
fn main() { | |
let a = 35; | |
let b = 42; | |
// copy the values and transfer | |
// ownership over the copies to print_sum: | |
print_sum(a, b); | |
// we still retain full control over | |
// the original a and b variables here | |
println!("We still have {} and {}", a, b); | |
// the original a and b are dropped and deallocated here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment