-
Notifications
You must be signed in to change notification settings - Fork 13.3k
u64::saturating_div is useless #122821
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
Comments
I think these functions mostly exist for consistency |
That's all very well, but surely this one should return |
"Consistency" isn't usually sufficient justification for having a method. Perhaps we should just deprecate these? |
I don't think this was the only reason. On the PR (#87921) for the It's also worth noting that if |
No, for signed type If |
It's not useless just because of this, it's useless because it has identical behavior to |
@Jules-Bertholet All of How is a non-existing function like (speaking of which there should also have been |
Then IMO these should be deprecated also. |
No it is not useless, consistency in integer methods is extremely useful for macro writers. The only issue is that |
Yeah, having this consistent integer methods makes writing macros easier (and it makes writing the standard library implementation macros easier :3), and they don't hurt. I think this should be closed. |
pub const fn saturating_div(self, rhs: u64) -> u64
This makes no sense. The only way that
u64 / u64
could overfllow is ifrhs = 0
.The same is true for the other unsigned integer types. The signed types have the excuse that they wouldn't know whether to count division by zero as saturating to -ve or +ve maximum.
The text was updated successfully, but these errors were encountered: