4 ms·
Actually; I'm not sure I'm wrong. If Copy was automatically derived based on fields of a struct (without the user explicitly asking for it with `#[derive(Copy)]
by aapoalas 1y ago
Actually; I'm not sure I'm wrong. If Copy was automatically derived based on fields of a struct (without the user explicitly asking for it with `#[derive(Copy)]` that is, as the parent comment suggested the OP is asking for), then your example S and the std Vec would both automatically derive Copy. Then, implementing Drop on them would become a compile error that you would have to silence by using the escape hatch to "un-derive" Copy from S/Vec.
So, whenever you wanted to implement Drop you'd need to engage the escape hatch.
- School-Cotton 1y agoWhat I suggested OP was asking for was: > all types that _can_ implement `Copy` should do so automatically unless you opt out , which was explicitly intended to exclude types with destructors, not > types should auto-derive `Copy` based purely on an analysis of their fields.
- tonyedgecombe 1y agoSo if you have some struct that you use extensively through an application and you need to extend it by adding a vector you are stuck because the change would need to touch so much code.