-
Notifications
You must be signed in to change notification settings - Fork 148
Implement Bounded, ToPrimitive, NumCast, FromPrimitive for NonZero* #334
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
Conversation
03bb963
to
eee8ac0
Compare
@acrrd |
eee8ac0
to
7f6c0e5
Compare
Curious about https://doc.rust-lang.org/stable/core/num/struct.NonZero.html as well (might need an MSRV-preserving feature-gate) |
done |
This needs nightly, |
@acrrd though the https://doc.rust-lang.org/stable/core/num/trait.ZeroablePrimitive.html#implementors Quite a bit of the functionality is already stable, as is noted in the feature gates in the rustdoc. Here's a small example: |
The old types are just aliases now, literally |
I'm torn on So if we add that, shouldn't we also do it for |
It was requested in #335, they have a use case for it. Let me know if you want to keep it.
We can't. The trait requires |
I'm going to respond there, because I think that use is also problematic, even aside from
I wasn't talking about any other traits, only |
7f6c0e5
to
acb1a26
Compare
done
I see it now, sorry |
To me, a big part of the value of add-on crates like the
For example, the concept you mentioned of "types where you could literally write x as T" is not expressible using any combination of traits from the standard library.
I think the difference is that Whereas |
This seems consistent to me -- Anyway, let me give this PR an actual review... |
@cuviper Do you think this is ok after the changes? |
Thanks! And sorry for the slow review. |
@cuviper do you plan to do a release soon with this? Is there any blocker I could help with? |
I have a use case where I convert to and from primitive, and I need to involve
NonZero*
types as well.Currently, I have a function that uses these traits for primitive types, and I have additional functions for each
NonZero*
that I need. It would be nice to get rid of them and have only one.I can create on PR per trait implementation if it's preferred. This PR has one commit per trait implementation.