Skip to content

Conversation

@ChayimFriedman2
Copy link

as_mut() cannot be used correctly, any usage will invoke UB. As the nomicon says:

  • Transmuting an & to &mut is Undefined Behavior. While certain usages may appear safe, note that the Rust optimizer is free to assume that a shared reference won't change through its lifetime and thus such transmutation will run afoul of those assumptions. So:
    • Transmuting an & to &mut is always Undefined Behavior.
    • No you can't do it.
    • No you're not special.

Best reviewed commit-by-commit

@ChayimFriedman2 ChayimFriedman2 force-pushed the avoid-ub branch 2 times, most recently from fa22064 to 7aa78e9 Compare April 17, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant