D. Ataro
D. Ataro

Reputation: 1831

Do all generic types implement the Copy trait?

Do all generic types in Rust implement the Copy trait? To expand upon this, are there a lot of types in the standard library that implement this trait, other than that of generic types?

Upvotes: 3

Views: 2277

Answers (1)

Shepmaster
Shepmaster

Reputation: 432189

Do all generic types in Rust contain the Copy trait?

No. That's why you have to explicitly request that a generic type implement Copy:

fn foo<T>(value: T)
    where T: Copy,
{
    // ...
}

are there a lot of types in the standard library that implement this trait,

See for yourself. A trait's documentation lists its known implementors.

Upvotes: 8

Related Questions