3 ms·
> The author is making the case for special treatment of structs for a special case. The struct by-copy is mostly a good API thing in a lot of scenarios, parti
by gopalv 7y ago
> The author is making the case for special treatment of structs for a special case.
The struct by-copy is mostly a good API thing in a lot of scenarios, particularly when the objects are <1 cache line.
Even more so, when you're only writing half the code and want to separate the actions within a function from any side-effects outside.
I would say that the performance difference for small structures is irrelevant to the extra hop, particularly if the copied location is the stack on the callee.
- fnord77 7y ago> Even more so, when you're only writing half the code and want to separate the actions within a function from any side-effects outside. Due to the default immutability of references and the fact the compiler won't allow you to won't allow you to share data between threads (without jumping through a lot of hoops), the risk of side-effects are pretty well neutralized. Another selling point of Rust.