4 ms·
Rust's own Aaron Turon put this nicely in a recent talk at Stanford. A data race requires all of the following: aliasing, mutation, and a lack of synchronizatio
by kibwen 12y ago
Rust's own Aaron Turon put this nicely in a recent talk at Stanford. A data race requires all of the following: aliasing, mutation, and a lack of synchronization. Rust's usual ownership rules already make aliasing exclusive with mutation, so out of the box you're safe. But when simultaneous aliasing and mutation is exactly what you want, as in a mutex, it's safe to subvert the type system as long as you make sure to uphold the synchronization aspect on your own (which Rust nicely helps with by leveraging ownership on the synchronization mechanism itself).
https://www.youtube.com/watch?v=O5vzLKg7y-k&t=31m00s https://www.youtube.com/watch?v=O5vzLKg7y-k&t=31m00s
- Animats 12y agoI was at that talk. In a sense, what you need there is not "unsafe", but "atomic", declaring that the contained operation is atomic. That's less general than "unsafe", and atomicity of code is checkable.