Skip to content

The heart example in docs for std::char primitive is ambiguous #36998

Closed
@ljedrz

Description

@ljedrz

I was going through the docs for std::char and found out that the heart is at first encoded with two codepoints (❤️) and just one afterwards (❤). This is misleading, as the difference is not visible in the browser (at least not in Chrome) and the reader first sees information that:

Trying to create a literal with let heart = '❤️'; gives an error

and afterwards there are perfectly valid examples like

for c in '❤'.escape_unicode() {
    print!("{}", c);
}

What makes matters worse is that they both start with the same code point; the second example I listed states that:

This prints:
\u{2764}

While in the first case there is:

assert_eq!(Some('\u{2764}'), iter.next());
assert_eq!(Some('\u{fe0f}'), iter.next());

I found this misleading and had to use a hex editor to discover the difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions