Answer Francis Gagné is the right answer for your case. However, I will say that there is a compiler option to disable overflow checking. I see no reason to use it, but it exists and may also be known:
use std::u8;
fn main() {
u8::MAX + u8::MAX;
}
Compiled and launched:
$ rustc overflow.rs
$ ./overflow
thread '<main>' panicked at 'arithmetic operation overflowed', overflow.rs:4
$ rustc -Z force-overflow-checks=no overflow.rs
$ ./overflow
$
source
share