Pre-RFC: Copy-like trait for large types

When we've discussed this in the past, we came to the conclusion that we should encourage the Copy trait to be more widely used, but to use a lint to guard against unexpected copies. This could be either because the value is large or because it contains interior mutability.

I remember that we made some decision in the iterator design that really encouraged the above approach, but I can't quite remember what it was (i.e., there was some point where we said "if we were going to have two traits, we would do it this way, but if we're only going to have one, we would do it that way" -- and we did it that way).

There is an open Rust issue on exploring this topic, #45683, as well.

2 Likes

One thing that has not come up yet in this topic is that Copy is useful for collections, independent of the size of T, for example in copy_from_slice.

Bringing a third trait into play would make those interfaces much harder.

It's only the places where "Copy or Reference" is a decision where that is a concern. There are other places where Copy matters.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.