Skip to content

format!() should support the same set of \-escapes that regular string literals do #9970

Closed
@lilyball

Description

@lilyball

As long as format!() treats \ as an escape character, it should handle all the same escapes that normal string literals do. This way a raw string literal can be passed to format!() and still use the expected escapes. Right now, attempting to do so:

println!(r#"this is a "string": {}\n"#, "example code");

throws a compiler error:

 error: invalid escape character `n`
println!(r#"this is a "string": {}\n"#, "example code");
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions