Skip to content

Instantly share code, notes, and snippets.

@kunigami
Created March 9, 2019 02:52
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/ee3f83fa396e1d8a158bdedfe8e32484 to your computer and use it in GitHub Desktop.
Save kunigami/ee3f83fa396e1d8a158bdedfe8e32484 to your computer and use it in GitHub Desktop.
fn mutate_vec(mut vec: Vec<i32>) -> Vec<i32> {
vec.push(4);
}
let mut vec1 = vec![1, 2, 3];
mutate_vec(vec1);
// Error: ownership transferred in function call
println!("{}", vec1.len());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment