News for hackers. Stuff that matters.
Re:There's No Such Thing as “Implicitly Atomic” by _nalply on Thursday October 05, 2023 @04:12PM (#37783698)
Why didn't you use a Mutex?
Re:There's No Such Thing as “Implicitly Atomic” by kevincox on Thursday October 05, 2023 @04:16PM (#37783744)
What are you thinking?

I could have used a Mutex then cast the `&Mutex` to `&mut Mutex` so that I could call `.get_mut()`. But this didn't seem simpler.

Re:There's No Such Thing as “Implicitly Atomic” by _nalply on Thursday October 05, 2023 @04:34PM (#37783948)
I wanted to avoid unsafe.

Because unsafe introduces conceptual complications and it seemed to be simpler to avoid that in an example.

Re:There's No Such Thing as “Implicitly Atomic” by kevincox on Thursday October 05, 2023 @04:40PM (#37784011)
Well you can't have a memory race without unsafe. The goal of the example was to show undefined behaviour.
Re:There's No Such Thing as “Implicitly Atomic” by _nalply on Thursday October 05, 2023 @04:56PM (#37784192)
Ah, you wanted to show an example in Rust with unsafe where atomicity was not guaranteed.