Skip to content

' \" ' works in char literals #32249

Closed
Closed
@Robbepop

Description

@Robbepop

To write a double-quote (") in a string literal, once needs to escape with with a backslash like so:

let s = "double-quote: \"";

This is because it is also the delimiter of a string.
However, in character literals a single-quote (') is the delimiter and still, '"' works without warnings:

assert_eq!('\"', '"'); // always true

I think this might be a bug since it is not really needed to have an escaped double-quote in character literals or was it implemented as a helpful routine?

The same is true for strings and a single-quote!

assert_eq!("\'", "'"); // always true

I am very sorry if this was explicitly wanted behaviour!

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions