I've stumbled upon a strange (to my point of view) behavior, though maybe I'm missing something in a rust runtime implementation. Following snippet describes the issue:
let mut num1: u8 = 300;
// works fine, just overflows the value
num1 += 1;
let mut num2: u8 = 255;
// panics with 'attempt to add with overflow'
num2 += 1;
So why the handling of such similar cases is different?
In both cases we have an overflow going on, but in the second case rust just panics like it can't overflow properly, which he just did for num1.
I'm running rustc 1.28.0 on darwin if it will help in any way.