You can make it on stable Rust by using an enum with a missing variant.
The compiler will give you a niche automatically.
Of course that doesn't scale to larger types as even with a macro the compile speed will be horrible.
Of course that doesn't scale to larger types as even with a macro the compile speed will be horrible.
Today, in practice, if you want BalancedI32 what you'd do is swizzle NonZeroI32, so that a trivial CPU operation converts between the two types and you can deliver almost the same optimisations in practice. But, I think that's also pretty ugly, and Rust clearly could do the nicer thing here, indeed it does in my crate that only builds on nightly and is using not-for-public-use compiler internal attributes. So that's what I want, just apparently not enough to spend my vacation time last month working on it. Maybe next month.