Hacker News new | ask | show | jobs
by Koiwai 1532 days 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.

1 comments

Or, 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