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

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

Krappa322
Copy link
Contributor

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
Contributor 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
Contributor 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
Contributor 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
Contributor Author

image
image

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs A-rustdoc-json Area: Rustdoc JSON backend O-wasi Operating system: Wasi, Webassembly System Interface T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 31, 2024
@rustbot

This comment was marked as resolved.

@Krappa322
Copy link
Contributor Author

oops - incorrect rebase - ignore

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Aug 31, 2024
@rustbot

This comment was marked as resolved.

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 rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Aug 31, 2024
@Krappa322
Copy link
Contributor Author

@rustbot review

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

Thanks! Great to be clearer here for people reading these docs.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 19, 2024

📌 Commit 467dbcb has been approved by scottmcm

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 19, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#128001 (Improve documentation for <integer>::from_str_radix)
 - rust-lang#130553 ([Clippy] Get rid of most `std` `match_def_path` usage, swap to diagnostic items.)
 - rust-lang#130554 (`pal::unsupported::process::ExitCode`: use an `u8` instead of a `bool`)
 - rust-lang#130556 (Mark the `link_cfg` feature as internal)
 - rust-lang#130558 (Support 128-bit atomics on s390x)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 767ae2b into rust-lang:master Sep 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 19, 2024
Rollup merge of rust-lang#128001 - Krappa322:master, r=scottmcm

Improve documentation for <integer>::from_str_radix

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs A-rustdoc-json Area: Rustdoc JSON backend O-wasi Operating system: Wasi, Webassembly System Interface S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

7 participants