What's the difference between trait Copy and Clone?

http://doc.rust-lang.org/stable/book/ownership.html#copy-types

Clone is explained here std::clone - Rust

The short explanation is "Clone is a way of copying a type that can run arbitrary code. Copy is a way of copying a type that just takes a memcpy." Since Clone is more general than Copy, you can automatically make anything Copy Clone as well.

In your case, they're the same. you're just using a different method.

11 Likes