You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think a more general thing here would be integral types with a fixed range. NonZeroI8 is just an i8 with range 1..=MAX. But it'd be nice to instead have BoundedI8<1, i8::MAX> or something. The compiler can optimize on the bounds then, as .get() could __assume() stuff about the returned value?
The NeverValueField would be the min_bound-1 or max_bound+1, assuming either one is not MIN/MAX.
Bounded type A should implicitly convert to Bounded type B if B has bounds which cover A, regardless of the actual storage type.
danakj
changed the title
Add sus::num::NonZero* types
Add sus::num::Bounded* types
Jun 13, 2023
The compiler can optimize on the bounds then, as .get() could __assume() stuff about the returned value?
Yes, as long as the method that returns the inner value is inlined, then the caller will optimize based on the bounds in Clang and GCC (MSVC does poorly but can clearly be improved).
Like https://doc.rust-lang.org/std/num/index.html
They should be NeverValueField types so they don't require an extra bool in Option.
The text was updated successfully, but these errors were encountered: