4 ms·
Maybe not fully ergonomic yet, but this exists today (at least for max): https://docs.rs/nonmax/latest/nonmax/ https://docs.rs/nonmax/latest/nonmax/ If you're
by eslaught 2y ago
Maybe not fully ergonomic yet, but this exists today (at least for max):
https://docs.rs/nonmax/latest/nonmax/ https://docs.rs/nonmax/latest/nonmax/
If you're really attached to it being min you'd have to copy that library.
Edit to add: we actually use these in one of my main Rust codes; they're useful, but I'm not sure they're so useful I'd want them built into the language.
- tialaramex 2y agoYeah, the XOR trick†. It's very affordable on modern hardware (your CPU can cheerfully XOR two registers while doing other things, barely measurable) but it's more the principle of the thing. Maybe I should just put up with the XOR trick and stop thinking about Pattern Types but I don't think I'll be able to. † Just in case you've never looked inside those types, they have a constant value and when you want a NonFoo you just take a NonZero and you XOR it with that constant, in other respects they work the same way as any other wrapper type. This is one reason the NonZero types exist, they make the XOR trick very easy to do.