Skip to content

Instantly share code, notes, and snippets.

@CodeSandwich
Created March 26, 2018 12:39
Show Gist options
  • Save CodeSandwich/558cbfc3ea09e6e2de9d2b97ffc9bac8 to your computer and use it in GitHub Desktop.
Save CodeSandwich/558cbfc3ea09e6e2de9d2b97ffc9bac8 to your computer and use it in GitHub Desktop.
fn valid_flow() {
let value = "abc".to_string(); // crate value
let borrow = &value; // create borrow
println!("{}", value); // use value without moving it
println!("{}", borrow); // use borrow
// delete borrow
// delete value safely, because
// it's no longer borrowed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment