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

FIX - Char documentation for unexperienced users #72371

Merged
merged 1 commit into from
May 21, 2020

Conversation

Elrendio
Copy link
Contributor

@Elrendio Elrendio commented May 20, 2020

This is my first PR on rust and even if I've read CONTRIBUTING.md I'm ensure everything is perfect. Sorry if I didn't follow the exact procedure.

What it does:

  • Add an example in the char documentation

Explanation
Unexperienced users might not know that punctuation is Case_Ignorable and not Uppercase and Lowercase which mean that when checking if a string is uppercase one might be tempted to write:

my_string.chars().all(char::is_uppercase)

However this will return false for "HELLO WORLD" which is not intuitive. Since the function is_case_ignorable doesn't exists I believe the correct way to check is:

!my_string.chars().any(char::is_lowercase)

The aim of this example is to prevent unexperienced users to make an error which punctuation chars.

@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 @LukasKalbertodt (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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2020
@Elrendio
Copy link
Contributor Author

r? @steveklabnik

src/libcore/char/methods.rs Outdated Show resolved Hide resolved
src/libcore/char/methods.rs Outdated Show resolved Hide resolved
@Elrendio
Copy link
Contributor Author

@lcnr Thanks for the review, I've fixed :)

Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks so much!

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented May 21, 2020

📌 Commit f5b4957 has been approved by steveklabnik

@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 May 21, 2020
RalfJung added a commit to RalfJung/rust that referenced this pull request May 21, 2020
…eklabnik

FIX - Char documentation for unexperienced users

This is my first PR on rust and even if I've read [CONTRIBUTING.md](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#pull-requests) I'm ensure everything is perfect. Sorry if I didn't follow the exact procedure.

**What it does:**
- Add an example in the char documentation

**Explanation**
Unexperienced users might not know that punctuation is `Case_Ignorable` and not `Uppercase` and `Lowercase` which mean that when checking if a string is uppercase one might be tempted to write:
```rust
my_string.chars().all(char::is_uppercase)
```

However this will return false for `"HELLO WORLD"` which is not intuitive. Since the function `is_case_ignorable` doesn't exists I believe the correct way to check is:
```rust
!my_string.chars().any(char::is_lowercase)
```

The aim of this example is to prevent unexperienced users to make an error which punctuation chars.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#71854 (Make `std::char` functions and constants associated to `char`.)
 - rust-lang#72111 (rustc-book: Document `-Z strip=val` option)
 - rust-lang#72272 (Fix going back in history to a search result page on firefox)
 - rust-lang#72296 (Suggest installing VS Build Tools in more situations)
 - rust-lang#72365 (Remove unused `StableHashingContext::node_to_hir_id` method)
 - rust-lang#72371 (FIX - Char documentation for unexperienced users)
 - rust-lang#72397 (llvm: Expose tiny code model to users)

Failed merges:

r? @ghost
@bors bors merged commit 0e88712 into rust-lang:master May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants