Copy and Marker Traits
We’ve previously talked about copyable types. As a reminder, those are types that are so cheap to clone that the compiler will do it for you automatically. Rust identifies these types with a special trait called Copy
. Copy
is known as a marker trait. That means it’s a trait that doesn’t provide any functionality on its own. Instead, it provides information to the compiler about a type, such as, “This type is cheap enough to copy.”
As an example, we could implement the Copy
trait for our parameterized Fruit
type like this: