Re:Comparative unsafety
by thaumasiotes on Friday April 09, 2021 @11:09AM
(#26751476)
I actually find ~0 more intuitive. u32::MAX makes me think the relevant concept is "a really big number"; ~0 makes me think the relevant concept is "a bunch of bits that are all 1s".
[ Parent
| on HN ]
Fair enough. But tbh I'm not sure it really matters in this context. It's just a constant that means "ignore this parameter". Whether it's "a really big number" or "a bunch of bits that are all 1s" is incidental.
Btw, you can directly express "all ones" in Rust as:
0b_1111_1111_1111_1111_1111_1111_1111_1111
Though it's somewhat less succinct. ;)EDIT: Added more ones, thanks adwn!
> 0b1111_1111_1111_1111
That's just 16 bits and will result in the value 65535, not -1.