Skip to content

Instantly share code, notes, and snippets.

@kunigami
Last active March 9, 2019 04:26
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/892dfadbc3b68fe5bacfbd98729eb3d7 to your computer and use it in GitHub Desktop.
Save kunigami/892dfadbc3b68fe5bacfbd98729eb3d7 to your computer and use it in GitHub Desktop.
let mut vec1 = vec![1, 2, 3];
{
let vec2 = &mut vec1;
// We can mutate s1's data via a mutable reference!
vec2.push(4);
// Error: cannot access data when a mutable
// reference is in place
println!("{}", vec1.len());
}
println!("{}", vec1.len());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment