Skip to content

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

Closed

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.

Activity

  1. munds commented on Feb 24, 2015

    @munds
    Contributor

    I also added this to the Hello World Tutorial, was that a bad thing?

  2. added a commit that references this issue on Nov 29, 2018
    8476749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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