How ownership of a Vec moves between variables and into a function, and who frees it
The compiled program has been loaded into memory, but no function has run yet. Nothing is on the stack and nothing is on the heap
1fn main() {2 let a = vec![1, 2, 3];3 let b = a;4 take(b);5}67fn take(v: Vec<i32>) {8 println!("{}", v.len());9}How ownership of a Vec moves between variables and into a function, and who frees it
Copy value moves its ownership.clone() deep-copies the heap data when you really need two independent ownersRc<T> and Arc<T> allow shared ownership by counting references instead$cargorun// waiting for the first println!