You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...and more generally, checked operation traits should not extend their unchecked counterparts.
I'd like to contribute a PR to implement CheckedAdd for the NonZero___ types in std::num, but it is not possible since they do not implement core::ops::Add (for good reason). The way to unblock my desired change is to make CheckedAdd not extend Add.
I suspect that removing the relationship between CheckedAdd and Add 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 extend CheckedAdd (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 into core::ops. If it is, then I am willing to pursue that course of action instead of making changes to num-traits.
The text was updated successfully, but these errors were encountered:
I suspect that removing the relationship between CheckedAdd and Add might be a breaking change,
Yes, that is a breaking change, sorry.
I wonder if the real "right" solution also involves getting checked operations into core::ops.
Those traits are all related to built-in language operators, so you can impl Add to get a working + operator on your own types. It's not impossible to think of having core traits for more numeric methods, but there's not any current precedent for that. Most of these num traits were in the standard library before Rust 1.0, and were kicked out to live here instead.
...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: