MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/rustjerk/comments/1x5d2lw/rust_devs_hate_this_one_simple_trick/pgpfqne/?context=3
r/rustjerk • u/CorgiApprehensive159 • Oct 14 '26
39 comments sorted by
View all comments
Show parent comment
7
It's not legitimate. unsafe can be fine to use, but undefined behavior is never allowed. Aliasing a mutable reference is undefined behavior.
unsafe
A workaround would be something like using mutable pointers rather than mutable references. Mutable pointers allow aliasing.
View all comments
Show parent comment
7
u/ChaiTRex Oct 14 '26
It's not legitimate.
unsafecan be fine to use, but undefined behavior is never allowed. Aliasing a mutable reference is undefined behavior.A workaround would be something like using mutable pointers rather than mutable references. Mutable pointers allow aliasing.