-
Notifications
You must be signed in to change notification settings - Fork 141
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
CheckedAdd
should probably not extend Add
#274
Comments
Yes, that is a breaking change, sorry.
Those traits are all related to built-in language operators, so you can |
Do you know where I can find any of the history of that decision? |
I found the commit history, but not much discussion. For this particular trait:
|
Can it be done like:
|
Major version of what? I don't know what you mean here.
No, because that makes the whole build fragile if one dependent wants it different than another. And if you really control the whole build, then you can just create a new trait that does what you want. |
...and more generally, checked operation traits should not extend their unchecked counterparts.
I'd like to contribute a PR to implement
CheckedAdd
for theNonZero___
types instd::num
, but it is not possible since they do not implementcore::ops::Add
(for good reason). The way to unblock my desired change is to makeCheckedAdd
not extendAdd
.I suspect that removing the relationship between
CheckedAdd
andAdd
might be a breaking change, so I figured I'd propose the idea before I start a PR for it.The presence of an unchecked add implies that a checked add is possible, but a checked add does not imply that an unchecked add is possible. I think that, if anything,
Add
should extendCheckedAdd
(though I realize the practical difficulties of that). Given the relationship between them, I wonder if the real "right" solution also involves getting checked operations intocore::ops
. If it is, then I am willing to pursue that course of action instead of making changes tonum-traits
.The text was updated successfully, but these errors were encountered: