The documentation of clone_from
says:
Performs copy-assignment from source.
a.clone_from(&b)
is equivalent toa = b.clone()
in functionality, but can be overridden to reuse the resources of a to avoid unnecessary allocations.
Why does clone_from
(copy-assignment) avoid unnecessary allocations? What is an example?
I think this is a well known concept in C++, but I don't have a strong C++ background.