-
Notifications
You must be signed in to change notification settings - Fork 390
Implement Sub/SubAssign for all Uint* types #1242
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
and improve consistency across Uint* types
ec3d339 to
4e4ccb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
My only suggestion - maybe .expect could include both numbers in message.
Plenty of times I stumbled upon some "anonymous" errors and had a lot of issues finding out which operation exactly failed - providing actual numbers might give some context.
Opinions?
| impl AllImpl<'_> for Uint64 {} | ||
| impl AllImpl<'_> for Uint128 {} | ||
| impl AllImpl<'_> for Uint256 {} | ||
| impl AllImpl<'_> for Uint512 {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
You mean adding a debug message to I would do this in cases where we loop over test data where the line alone does not tell you exactly which test is failing. But we don't have this often. |
| Uint64( | ||
| self.u64() | ||
| .checked_sub(rhs.u64()) | ||
| .expect("attempt to subtract with overflow"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No no, I meant strictly cases like here - but I just realized, that .expect takes &str as an argument.
So we can't do, for example, format!() here to create some nice String with local variables (at least not cheap - without any copy etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point. Yeah, this is pretty inconsistent anyways. Sometimes we just .unwrap(), sometimes we create out own message. Let's keep this in mind and address it separately.
For #1186