|
|
|
|
|
by sshine
1251 days ago
|
|
Rust does have a fix for this: error: this arithmetic operation will overflow
--> src/main.rs:2:18
|
2 | let a: u64 = u64::MAX + 1;
| ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
Rust also allows for overflowing arithmetic (preserving the default to fail):https://doc.rust-lang.org/std/?search=overflowing It's generally less ergonomic, e.g. let (zero, _did_overflow) = u64::MAX.overflowing_add(1);
|
|