There is a long-approved but also long-delayed breaking change coming down the pipeline. The idea is that struct/enum types will no longer be implicitly copyable, even if they contain POD data. They will move from place to place just like a Box
etc.
For types that should be implicitly copyable, you can manually implement Copy
. This can be done most easily by writing #[deriving(Copy)]
(or, more likely, throwing Copy
into a #[deriving]
you already have).
There is also a lint that warns you if you have a type that could be copy but is not. The intention is to help you ensure that you do not forget to derive Copy
when it is necessary. The idea is that if you have a type that is copyable but you don’t want to guarantee that for API compatibility, you can annotate it with a #[allow()]
.
This is part of the opt-in-builtin-types RFC.
UPDATE: See this note about a temporary feature-gate that may aid you in transitioning.