What is the Rust equivalent of a C++ std::atomic<std::pair<void*, int>> ?

34 points XiPingTing

C++ Concurrency in Action discusses lock-free data structures. These pack a pointer with a counter and manipulate them as a single atomic unit (emitting cmpxchg16b assembly instructions). Can this be done in Rust? Looking at https://doc.rust-lang.org/std/sync/atomic/ , I'm concerned Rust might not allow packed atomics like this. Or have I missed something?

​

Clearly this has the ownership safety of a chainsaw juggler, but... can it be done?