Skip to content
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

Open
ActuallyHappening opened this issue Apr 23, 2024 · 1 comment
Open

NonZero* types for BigInt and related numbers #435

ActuallyHappening opened this issue Apr 23, 2024 · 1 comment

Comments

@ActuallyHappening
Copy link

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 to NonZeroBigInt when I realised that NonZeroBigInt 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 type NonZeroBigInt and related types (e.g. NonZeroBigUInt)?
Thanks

@cuviper
Copy link
Member

cuviper commented Apr 23, 2024

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 Vec though, which was greatly expanded in rust-lang/rust#106790 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants