#Choice of assignment option question
6 messages · Page 1 of 1 (latest)
Ownership manages freeing
Giving ownership of str1 to str2 doesn't free str1, it makes str2 the owner. Then, when str2 goes out of scope, it's freed.
Something is freed when there is no more owner
Other than that, sounds accurate
The difference between using a reference and cloning goes beyond what can be freed. Making a clone uses more memory and takes more time, because a full replica of the data is made. A reference doesn't make a replica. It just refers to the original data. It is possible to make a mutable clone and modify it without the original being changed, because it's a completely independent duplicate of the data.