3 ms·
If you really believe your users won't understand this is a ~4K object and might foolishly copy it when they didn't mean to, implement Clone instead so that the
by tialaramex 5y ago
If you really believe your users won't understand this is a ~4K object and might foolishly copy it when they didn't mean to, implement Clone instead so that they can have another one if that's what they really meant.
If you're exaggerating and the object is really 64 bytes, just suck it up and derive Copy, your estimate of how "expensive" it is may well be so wrong that you're defeating your own objectives.
I've never seen any indication that unneeded PartialEq or Debug for example aren't elided by the compiler. In contrast if I need Debug it sure is a pain in the backside to implement it manually in a wrapper type because the owner of the type decided unilaterally that nobody would need that.
- kvark 5y agoI want to see the costs in the code, not imply them. Also, profiling programs in Rust often shows full of memcopies. Saying that they are nicely optimized out is dishonest.