Replies: 1 comment
-
True! The point here is that Rust does all its analysis in isolation. So even though this example is safe, the compiler doesn't know this — it basically assumes the worst case, which is that some other thread will mutate the variable concurrently.
Taking out the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just staring at the code, it isn't really clear what the potential data races are here. After all, this is a sequential program that first increments something, then prints it.
I think you either need to explain what the potential races are, or suggest people take out the
unsafe
keywords and see what the compiler says:... which is basically that it would be a problem if the program were multi-threaded (which it isn't!)
Beta Was this translation helpful? Give feedback.
All reactions