-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Update to_uppercase docs to avoid ß->SS example #150902
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
Merged
rust-bors
merged 3 commits into
rust-lang:main
from
guilhermeljs:docs-150888-to_uppercase
Jan 14, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1143,11 +1143,12 @@ impl char { | |
| /// [Unicode Standard]: https://www.unicode.org/versions/latest/ | ||
| /// | ||
| /// # Examples | ||
| /// `'ffi'` (U+FB03) is a single Unicode code point (a ligature) that maps to "FFI" in uppercase. | ||
| /// | ||
| /// As an iterator: | ||
| /// | ||
| /// ``` | ||
| /// for c in 'ß'.to_uppercase() { | ||
| /// for c in 'ffi'.to_uppercase() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would make sense to leave a comment explaining that this is a single codepoint? It might be a bit confusing otherwise, as people are likely to not know that these exist (I didn't) |
||
| /// print!("{c}"); | ||
| /// } | ||
| /// println!(); | ||
|
|
@@ -1156,13 +1157,13 @@ impl char { | |
| /// Using `println!` directly: | ||
| /// | ||
| /// ``` | ||
| /// println!("{}", 'ß'.to_uppercase()); | ||
| /// println!("{}", 'ffi'.to_uppercase()); | ||
| /// ``` | ||
| /// | ||
| /// Both are equivalent to: | ||
| /// | ||
| /// ``` | ||
| /// println!("SS"); | ||
| /// println!("FFI"); | ||
| /// ``` | ||
| /// | ||
| /// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string): | ||
|
|
@@ -1171,7 +1172,7 @@ impl char { | |
| /// assert_eq!('c'.to_uppercase().to_string(), "C"); | ||
| /// | ||
| /// // Sometimes the result is more than one character: | ||
| /// assert_eq!('ß'.to_uppercase().to_string(), "SS"); | ||
| /// assert_eq!('ffi'.to_uppercase().to_string(), "FFI"); | ||
| /// | ||
| /// // Characters that do not have both uppercase and lowercase | ||
| /// // convert into themselves. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hh... hmm. Would it be better to move this comment to a Rust comment inside the example code block so that it's directly visible in-context and likely to be copied with it?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@workingjubilee
If we move the note into a Rust comment inside the first example, wouldn't it seem local to that specific snippet? Because here we have three snippets that demonstrate the same semantic fact ('ffi' to "FFI"), just through different APIs (iteration vs println! vs assert). Putting the explanation in only one of them wouldn't make the other appear to lack the key context?, and I feel like duplicating the same comment in all of them would introduce redundancy. (maybe i'm overthinking it, and you have a great point about being likely to be copied with it)
I think keeping it as an introduction note makes it clear that it applies to the entire Examples section. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my eyes glazed over and failed to fully process the rest of the diff, it seems!
...Yyyyes, I think it's either "once" or "repeated per-instance", and at that point I am less sure of either choice as I think there is still merit of keeping the note close but redundancy is, well, redundancy.