Help with handling state

unsafe does not permit you to do things that Rust disallows; unsafe only permits you to tell the borrow checker that you have taken on the responsibility of proving correctness in situations that are too complex for the borrow checker itself to make such proofs. Anytime you do things that Rust disallows, you are probably UB, and thus have given the compiler permission to optimize your code to do things that you did not intend. Therein lie both incorrect results and vulnerabilities to malware.

5 Likes