4 ms·
In Rust the simplest way would be to use the `u32::MAX` constant. Create a fun alias for it if you want to express intent.
by ChrisSD 6y ago
In Rust the simplest way would be to use the `u32::MAX` constant. Create a fun alias for it if you want to express intent.
- thaumasiotes 6y agoI 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".
- ChrisSD 6y agoFair 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!