4 ms·
I must point out that Rust standard library includes std::mem::swap, which provides your safe atomic swap primitive. It is implemented using unsafe, but the int
by sanxiyn 12y ago
I must point out that Rust standard library includes std::mem::swap, which provides your safe atomic swap primitive. It is implemented using unsafe, but the interface is safe.
Historically, swap actually was a part of Rust language (operator <->). It was removed from the language as a primitive, because it can be implemented in a library.