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

Improve documentation for <integer>::from_str_radix #128001

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Krappa322
Copy link

Two improvements to the documentation:

  • Document - as a valid character for signed integer destinations
  • Make the documentation even more clear that extra whitespace and non-digit characters is invalid. Many other languages, e.g. c++, are very permissive in string to integer routines and simply try to consume as much as they can, ignoring the rest. This is trying to make the transition for developers who are used to the conversion semantics in these languages a bit easier.

Two improvements to the documentation:
- Document `-` as a valid character for signed integer destinations
- Make the documentation even more clear that extra whitespace and non-digit characters is invalid. Many other
  languages, e.g. c++, are very permissive in string to integer routines and simply try to consume as much as they can,
  ignoring the rest. This is trying to make the transition for developers who are used to the conversion semantics in
  these languages a bit easier.
@rustbot
Copy link
Collaborator

rustbot commented Jul 20, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @scottmcm (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 20, 2024
@Krappa322
Copy link
Author

Krappa322 commented Jul 20, 2024

In case the built documentation is inconvenient to access:

image

library/core/src/num/mod.rs Outdated Show resolved Hide resolved
@Krappa322
Copy link
Author

And some screenshots again, for convenience:

image
image

@rust-log-analyzer

This comment has been minimized.

@scottmcm
Copy link
Member

Thanks for including the screenshot; this is looking great!

One request: can you put an example of the error case too? I think there's a bunch of people who are less likely to read the text in detail, but a assert_matches!("1 ".parse(), Err(_)); or similar test should help emphasize.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 28, 2024
@Krappa322
Copy link
Author

Apologies for the long wait time :)

Added an error example for trailing characters. Didn't seem like there were that strong feelings on the macro syntax and I'm not really in the mood for macro development right now so I'll leave that as is if you all agree.

image
image

@rust-log-analyzer

This comment has been minimized.

@Krappa322
Copy link
Author

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants