What if rust got "unchecked" (unsafe) versions of arithmetic operations that have C arithmetic semantics. Kind of the opposite of "checked_add".
Re:The Value of Undefined Behavior
by steveklabnik on Sunday July 22, 2018 @04:17AM
(#17585811)
It’s possible! Nobody has ever proposed it...
* overflow is a “program error”, not UB
* compilers must either check for overflow and panic, or two’s compliment wrap
* when debug_assertions are on, implementations are required to panic on overflow
This means release mode wraps today, but if it’s cheap enough someday, we could make it panic.
If you want specific semantics on overflow, then you should use the various wrappers and/or methods that let you do them directly, rather than relying on any of the above. But you don’t have to specify; by default, the above is the semantics.