Skip to content

Commit 8476749

Browse files
jxclManishearth
authored andcommitted
Added documentation of backslash ending string literals.
Closes rust-lang#22698
1 parent ca71745 commit 8476749

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

reference.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ nonzero_dec: '1' | '2' | '3' | '4'
302302

303303
A _character literal_ is a single Unicode character enclosed within two
304304
`U+0027` (single-quote) characters, with the exception of `U+0027` itself,
305-
which must be _escaped_ by a preceding U+005C character (`\`).
305+
which must be _escaped_ by a preceding `U+005C` character (`\`).
306306

307307
##### String literals
308308

@@ -311,6 +311,19 @@ A _string literal_ is a sequence of any Unicode characters enclosed within two
311311
which must be _escaped_ by a preceding `U+005C` character (`\`), or a _raw
312312
string literal_.
313313

314+
A multi-line string literal may be defined by terminating each line with a
315+
`U+005C` character (`\`) immediately before the newline. This causes the
316+
`U+005C` character, the newline, and all whitespace at the beginning of the
317+
next line to be ignored.
318+
319+
```rust
320+
let a = "foobar";
321+
let b = "foo\
322+
bar";
323+
```
324+
325+
`a` is equivalent to `b`.
326+
314327
##### Character escapes
315328

316329
Some additional _escapes_ are available in either character or non-raw string

0 commit comments

Comments
 (0)