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
Copytrait is a subtrait ofClone, so you always need to implementCloneif you implementCopy:This makes sense, as both
CopyandCloneare ways of duplicating an existing object, but with different semantics.Copycan duplicate an object by just copying the bits that make up the object (likememcpyin C).Clonecan be more expensive, and could involve allocating memory or duplicating system resources. Anything that can be duplicated withCopycan also be duplicated withClone.