Commit 0e88712
authored
Rollup merge of rust-lang#72371 - Elrendio:char_documentation, r=steveklabnik
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.1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
812 | 812 | | |
813 | 813 | | |
814 | 814 | | |
815 | | - | |
| 815 | + | |
816 | 816 | | |
| 817 | + | |
817 | 818 | | |
818 | 819 | | |
819 | 820 | | |
| |||
843 | 844 | | |
844 | 845 | | |
845 | 846 | | |
846 | | - | |
| 847 | + | |
847 | 848 | | |
| 849 | + | |
848 | 850 | | |
849 | 851 | | |
850 | 852 | | |
| |||
0 commit comments