I think the code below could return "comparison is useless due to type limits".
Here, I test if a u8
is greater than u8::max_value()
, which is not possible.
I guess the compiler is checking whether the right-hand value can be fitted within an u8
.
#![allow(unused)]
fn main() {
println!("Largest u8: {}", u8::max_value());
let i = u8::max_value();
// The code below could be catched as an attempt to make a
// comparison that is "useless du to type limits",
// just as it would `if i > 1000` would.
if i > u8::max_value() {
println!("yes");
}
}