-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Implement Div for Wrapping<T> #26885
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
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Ah hmm I seem to have misunderstood the stability attribute. |
|
||
#[inline(always)] | ||
fn div(self, other: Wrapping<$t>) -> Wrapping<$t> { | ||
Wrapping(self.0 / other.0) |
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.
This should look like Wrapping(self.0.wrapping_div(other.0))
; currently your code will panic rather than overflow on MIN/-1
∀ signed integers.
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 yes, I hadn't looked properly.
Just call feature |
Resolves #26867