-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NonZero*
types for BigInt
and related numbers
#435
Comments
It's possible to express this, but I am adverse to duplicating a bunch of API surface on such types, and there would not be any niche benefit since the value is behind a heap allocation. We do already get niches from the inner |
I'm considering writing a library specifically for expressing a wrapping newtype pattern which only restricts the valid values of the inner type using a simple derive macro, e.g. NoWhitespaceString or NonZeroMyNum The ability to express invariants in my type that then get 'magically' applied to serde, std::fmt::Display/Debug e.t.c. is one feature of Rust I very much enjoy |
Hey guys,
I'm wanting to express certain invariants in my rust types while also handling arbitrarily large numbers, and so was refactoring from
NonZeroI32
toNonZeroBigInt
when I realised thatNonZeroBigInt
doesn't actually exist, and no analogue to this type already exists.Even if the compiler doesn't do niche-value optimisation as I think
NonZeroI32
and related std library types do, can we still get a typeNonZeroBigInt
and related types (e.g.NonZeroBigUInt
)?Thanks
The text was updated successfully, but these errors were encountered: