3 ms·
That's correct. Rust provides four versions of fundamental arithmetic for the integer types: * Checked where you get Some(answer) or None * Overflowing where
by tialaramex 5y ago
That's correct. Rust provides four versions of fundamental arithmetic for the integer types:
* Checked where you get Some(answer) or None
* Overflowing where you get (answer,false) or (overflowed_answer,true)
* Saturating where you get answer or the closest of type:::MIN and type::MAX to the correct answer
* Wrapping where the number line wraps around at the end
If you don't pick which you wanted, but then you do something that's poorly defined a debug build will panic, whereas a production build wraps.
The panic in debug is to encourage you to actually decide which of the four operations you meant and write that.