3 ms·
It's called destructuring assignment, it's not just for "in-place swap", and more over, it's about syntax, not performance. That article is talking about perfo
by Koiwai 4y ago
It's called destructuring assignment, it's not just for "in-place swap", and more over, it's about syntax, not performance.
That article is talking about performance, and as many have pointed out, it's better just use a 3rd variable(when there's no destructuring assignment) to swap and let compiler do its work.
I'm not saying syntax sugar is a bad thing.
- tialaramex 4y agoOr, express directly what you intended and let the compiler and library do it: e.g. https://doc.rust-lang.org/core/mem/fn.swap.html https://doc.rust-lang.org/core/mem/fn.swap.html