I've been doing some reading about the Copy trait, specifically about the choice to mark copy-able types with a trait instead of using a keyword (e.g. something like Swift's struct vs class).
From what I understand, traits generally have two roles - to describe an interface, and/or to enforce a contract. Copy seems to fall into the second category (considering that it's a marker trait I don't see how it could be an interface), but unlike other marker traits (e.g. Send and Sync), I've never seen Copy show up in a trait bound.
I was curious to know if any of you have seen or used Copy as a bound, and/or know of any situations where that would be useful.
("Probably" as there's not a 1-to-1 between Copy and "cheap"; Rc/Arc are pretty cheap to clone and large arrays of copyable types may be expensive to copy.)
I don't see the utility of a keyword over a trait here though.
Consider this example I wrote the other day: Rust Playground
You can remove the Copy bound and see all of the errors that it produces. The compiler happily tells you to add the trait bound back. Since the function accepts numeric types, Clone doesn't really make sense, here.
I use Copy bounds when it really doesn’t make sense for the param to be non-Copy (eg. 99% of the time a primitive type or a small simple struct) and having to sprinkle clone()s around would just make the code messy. You can always remove the bound if a use case appears later.