Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Member

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?

@guilhermeljs guilhermeljs Jan 11, 2026

Copy link
Copy Markdown
Contributor Author

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?

@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?

Copy link
Copy Markdown
Member

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.

///
/// As an iterator:
///
/// ```
/// for c in 'ß'.to_uppercase() {
/// for c in ''.to_uppercase() {

@Noratrieb Noratrieb Jan 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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!();
Expand All @@ -1156,13 +1157,13 @@ impl char {
/// Using `println!` directly:
///
/// ```
/// println!("{}", 'ß'.to_uppercase());
/// println!("{}", ''.to_uppercase());
/// ```
///
/// Both are equivalent to:
///
/// ```
/// println!("SS");
/// println!("FFI");
/// ```
///
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
Expand All @@ -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!(''.to_uppercase().to_string(), "FFI");
///
/// // Characters that do not have both uppercase and lowercase
/// // convert into themselves.
Expand Down
Loading