Skip to content
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

doc: improve None condition doc for checked_div and checked_rem #46947

Merged
merged 1 commit into from
Jan 6, 2018

Conversation

tspiteri
Copy link
Contributor

This commit improves the condition mentioned in the docs for which checked_div and checked_rem return None.

For signed division, the commit changes "the operation results in overflow" to "the division results in overflow", otherwise there is room for misinterpretation for checked_rem: Without considering overflow, MIN % -1 would be simply zero, allowing the misinterpretation that "the operation" does not result in overflow in this case. This ambiguity is removed using "when the division results in overflow".

For unsigned division, the condition for None should be simply when rhs == 0, as no other overflow is possible.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aidanhs (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@aidanhs
Copy link
Member

aidanhs commented Dec 24, 2017

r? @steveklabnik maybe?

@kennytm kennytm added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Dec 27, 2017
@alexcrichton alexcrichton added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 4, 2018
@frewsxcv
Copy link
Member

frewsxcv commented Jan 6, 2018

makes sense to me! thanks for clarifying this

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 6, 2018

📌 Commit f2c5472 has been approved by frewsxcv

kennytm added a commit to kennytm/rust that referenced this pull request Jan 6, 2018
…ewsxcv

doc: improve None condition doc for `checked_div` and `checked_rem`

This commit improves the condition mentioned in the docs for which `checked_div` and `checked_rem` return `None`.

For signed division, the commit changes "the operation results in overflow" to "the division results in overflow", otherwise there is room for misinterpretation for `checked_rem`: Without considering overflow, `MIN % -1` would be simply zero, allowing the misinterpretation that "the operation" does not result in overflow in this case. This ambiguity is removed using "when the division results in overflow".

For unsigned division, the condition for `None` should be simply when `rhs == 0`, as no other overflow is possible.
bors added a commit that referenced this pull request Jan 6, 2018
Rollup of 7 pull requests

- Successful merges: #46947, #47170, #47190, #47205, #47217, #47220, #47230
- Failed merges: #47233
@bors bors merged commit f2c5472 into rust-lang:master Jan 6, 2018
@tspiteri tspiteri deleted the checked-div-rem-none branch January 7, 2018 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants