2

If I do this:

for i in 0..std::u8::MAX {
    println!("{}", i);
}

then 255 is not included.

However, MAX+1 makes an overflow…

So, is there a simple way (without casting to u16) of enumerating all u8 integers?

Thanks.

Thomas Hugel
  • 146
  • 1
  • 5
  • 2
    To apply the other answer here: you can do `for i in 0..=u8::MAX` (note that as of the latest stable, Rust 1.43, you should be using [the associated constant `u8::MAX`](https://doc.rust-lang.org/nightly/std/primitive.u8.html#associatedconstant.MAX) and not [the one in the `std::u8` module](https://doc.rust-lang.org/nightly/std/u8/constant.MAX.html), which has been soft-deprecated). – trent May 02 '20 at 01:53

0 Answers0