Skip to content

Instantly share code, notes, and snippets.

@bugaevc
Last active April 27, 2016 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugaevc/e9f4db6a4819bc212dc08bad54528c3b to your computer and use it in GitHub Desktop.
Save bugaevc/e9f4db6a4819bc212dc08bad54528c3b to your computer and use it in GitHub Desktop.
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