Re:Ask HN: Why do you use Rust, when D is available?
by zRedShift on Friday June 12, 2020 @11:05AM
(#23499967)
Of course. rustc has the "-C overflow-checks" flag. Cargo turns it on by default for debug builds. To turn it on for release builds, just put "overflow-checks = true" in the [profile.release] section of your Cargo.toml.
Or better yet, the Rust standard library exposes all the relevant LLVM intrinsics for the primitives, so you have the {Integer}::checked_, {Integer}::saturating_, {Integer}::wrapping_, {Integer}::overflowing_ (inlined) functions to do all your integer math in an error-free fashion.
For example, is there a way in rust to get a runtime error when there's an int overflow?