Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kunigami
Last active March 13, 2019 18:03
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 kunigami/e2255c39fd8e3618d634997a1e4d7ae0 to your computer and use it in GitHub Desktop.
Save kunigami/e2255c39fd8e3618d634997a1e4d7ae0 to your computer and use it in GitHub Desktop.
let vec1 = vec![1, 2, 3];
{
// & indicates a reference, so we are not transferring
// ownership, just borrowing
let vec2 = &vec1;
println!("{}", &vec2);
}
// vec1 still has access to the data, since there was no
// ownership transfer
println!("{}", vec1.len());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment