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

Add CheckedNumOps #314

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add CheckedNumOps #314

wants to merge 3 commits into from

Conversation

cod10129
Copy link

Working with numerics in num-traits is biased towards using the standard traits, which is generally good. However, checked arithmetic is lacking a unifying trait (like NumOps). This PR adds that.
This trait should theoretically be a supertrait of PrimInt. However, this trait (like NumOps: Rem), requires CheckedRem. PrimInt does not currently require that, meaning that this would be a breaking change. (PrimInt: CheckedNumOps for a future release?)

@cuviper
Copy link
Member

cuviper commented May 3, 2024

This trait should theoretically be a supertrait of PrimInt. However, this trait (like NumOps: Rem), requires CheckedRem. PrimInt does not currently require that, meaning that this would be a breaking change. (PrimInt: CheckedNumOps for a future release?)

I think it's just that CheckedRem didn't exist at the time. Yes, it would make sense, but also yes, it would be a breaking change.

You did not actually include CheckedNumOps: CheckedRem though -- did you mean to?

cod10129 added 2 commits May 23, 2024 11:05
I think this is the right thing to do here, but I'm not entirely sure.
@cod10129
Copy link
Author

I wrote all that out about it and forgot to actually require CheckedRem. I think my idea was that I'm not sure what should happen with it. CheckedNumOps could not require CheckedRem and be a supertrait of PrimInt, or it could require CheckedRem and be disconnected from PrimInt. I wasn't sure on the best course of action, so I think that's why I left CheckedRem out.
However, now I think that using CheckedRem is the right way to go. If you don't think so you can roll back the most recent commit to the fork, which actually adds CheckedRem.

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

Successfully merging this pull request may close these issues.

2 participants