This makes sense, as both Copy and Clone are ways of duplicating an existing object, but with different semantics. Copy can duplicate an object by just copying the bits that make up the object (like memcpy in C). Clone can be more expensive, and could involve allocating memory or duplicating system resources. Anything that can be duplicated with Copy can also be duplicated with Clone.
0
diogovk
On
This happens because the trait Copy, depends on the trait Clone.
The compiler will not try to infer and implement the trait for you.
So you must explicitly implement the Clone trait as well.
The
Copy
trait is a subtrait ofClone
, so you always need to implementClone
if you implementCopy
:This makes sense, as both
Copy
andClone
are ways of duplicating an existing object, but with different semantics.Copy
can duplicate an object by just copying the bits that make up the object (likememcpy
in C).Clone
can be more expensive, and could involve allocating memory or duplicating system resources. Anything that can be duplicated withCopy
can also be duplicated withClone
.