Default type behavior for arithmetic #2478
Replies: 2 comments 7 replies
-
@yancyribbens please be cognizant that this is not a trivial issue to solve and requires quite a lot of brain power for the dev and the reviewers. We are pretty much overstretched at the moment (like all projects) and are working like mad at crate smashing and trying to stabalize. I do think the unit types need work but I think it can/should be done when |
Beta Was this translation helpful? Give feedback.
-
The reason |
Beta Was this translation helpful? Give feedback.
-
Soliciting some discussion about how the type behavior for arithmetic such as Addition and Subtraction should work. For example,
Weight
andAmount
have different semantics forAddition
andSubtraction
.Behold the add trait for Weight:
By contrast, the add trait for Amount:
The two behaviors are different; one of them is a
checked_add
while the other isunchecked
(raw?). Is there any good reason why these defaults should be different? To try and focus the discussion, I'm primarily asking:Even though there's an argument for panic in release mode being safer than allowing a possible overflow, does having the possibility of a panic preclude monodic error handling?
Lastly, there is performance implications for checked arithmetic that personally I'd like a way to "opt out of" in release mode for
Amount
andSignedAmount
as talked about here: #2434Beta Was this translation helpful? Give feedback.
All reactions