Skip to content

End-of-line backslash in string literal should be documented #22698

Closed
@MicahChalmer

Description

@MicahChalmer

Rust has a feature in non-raw string literals where a backslash right before a newline causes that newline, plus all whitespace at the beginning of the next line, to be ignored. That makes it so that you can indent the insides of string literals without the indentation being part of the program. For instance:

fn main() {
    println!("foo\
              bar");
}

prints foobar.

That's is a nice feature, but it appears nowhere (at least nowhere obvious that I can find from a brief search) in either in the book or the reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions