4 ms·
In this case more important than any runtime overflow/underflow checks is the fact that the compiler will check that comparison operands are of the same type in
by yakubin 3y ago
In this case more important than any runtime overflow/underflow checks is the fact that the compiler will check that comparison operands are of the same type instead of inserting an implicit cast. Instead the programmer is forced to insert an explicit conversion like .try_into().unwrap(), which clearly suggests the possibility of an error. And if the error isn't handled, it will panic.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=73ab2fde7f46f5d7e94b5156aa8951dd https://play.rust-lang.org/?version=stable&mode=debug&editio...
- yakubin 3y agoA similar warning could be enabled in GCC using the flag -Wsign-compare.