Last active
March 13, 2019 18:03
-
-
Save kunigami/e2255c39fd8e3618d634997a1e4d7ae0 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
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