3 ms·
> So it can, case closed. Being encouraged or not, doesn't control the hands of those typing the code. Sure in theory. But in practice most consider such a be
by unionpivo 6y ago
> So it can, case closed. Being encouraged or not, doesn't control the hands of those typing the code.
Sure in theory.
But in practice most consider such a behavior a code small or straight bug an d fix it.
So there is a difference in practice.
- pjmlp 6y agoIn theory every expert level C developer writes correct code, in practice errors happen.
- estebank 6y agoThe gp is slightly incorrect: in Rust you cannot override the constructor so that it allocates more than the struct itself. You can extend + and allocate in it, which is why it is treated in theory and practice as if it were a method call, because it is. You cannot override the assignment operator, it will always be either a conceptual move of ownership or a memcopy at worst, never a method call with any arbitrary number of heap allocations. Same for the dereferencing operator, it cannot be overriden. This is the reason we say there are no hidden allocations in Rust. In every language you might have allocations in a method call. Some languages consider assignment to be one for example, Rust doesn't.