Borrowing and lifetime
We have used references in our code. A reference is an instance in the stack that points to another instance. Let's recall what an instance memory usage looks like:
Stack: ☐☒☐☐☐☐☐☐☐☐☐☐
↓
Heap: ☐☒☒☒☒☐☐☐☐☐☐☐
A reference is allocated in stack memory, pointing to another instance:
Stack: ☐☒←☒☐☐☐☐☐☐☐☐
↓
Heap: ☐☒☒☒☒☐☐☐☐☐☐☐
Allocating in the stack is cheaper than allocating in the heap. Because of this, using references most of the time is more efficient than cloning...