-
Notifications
You must be signed in to change notification settings - Fork 47
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
Wrapper types? #63
Comments
I've been considering that, perhaps, this would be more appropriate for something like ranged-ints/ |
If multiple other crates have a shared need for some wrapper, they can collaborate on a common crate, but I definitely don't want to get into implementing all possible number categories here. :) |
good point 👍
I totally agree! haha. There's literally infinite of them. Even niche ones such as I propose we only focus on simple, everyday stuff, such as |
Honestly, I'd rather see even the simple stuff developed in their own crate. If it needs small additions in |
I agree, especially considering rust-num/num#421 |
Taking inspiration from
NonZero<T>
and Type-driven parsing, what if this crate (or a separate one, for organizing) provided wrappers for specific numeric properties?Strawman examples (not tested as compilable):
New fns could be defined that take advantage of such types. If a fn requires a
Prime
to work properly and safely, it'll no longer have to check primality by itself!The compiler could optimize code using
Even
orOdd
to have the same size and alignment asOption<Even | Odd>
(because LSB is unused).Existing fns could use these types to guarantee stuff such as
If
num
provided such types, there would be less crates implementing their own wrappers, or worse, doing redundant expensive checks:If there was 1:
The text was updated successfully, but these errors were encountered: