mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Rollup merge of #22748 - jxcl:string-backslash, r=steveklabnik
r? @steveklabnik Closes #22698 I wasn't sure that this was appropriate for the book, but I've added this to the reference. I also noticed that one of the U+ symbols in the character literals section was missing the graves.
This commit is contained in:
commit
08c25f37df
@ -302,7 +302,7 @@ nonzero_dec: '1' | '2' | '3' | '4'
|
||||
|
||||
A _character literal_ is a single Unicode character enclosed within two
|
||||
`U+0027` (single-quote) characters, with the exception of `U+0027` itself,
|
||||
which must be _escaped_ by a preceding U+005C character (`\`).
|
||||
which must be _escaped_ by a preceding `U+005C` character (`\`).
|
||||
|
||||
##### String literals
|
||||
|
||||
@ -311,6 +311,19 @@ A _string literal_ is a sequence of any Unicode characters enclosed within two
|
||||
which must be _escaped_ by a preceding `U+005C` character (`\`), or a _raw
|
||||
string literal_.
|
||||
|
||||
A multi-line string literal may be defined by terminating each line with a
|
||||
`U+005C` character (`\`) immediately before the newline. This causes the
|
||||
`U+005C` character, the newline, and all whitespace at the beginning of the
|
||||
next line to be ignored.
|
||||
|
||||
```rust
|
||||
let a = "foobar";
|
||||
let b = "foo\
|
||||
bar";
|
||||
|
||||
assert_eq!(a,b);
|
||||
```
|
||||
|
||||
##### Character escapes
|
||||
|
||||
Some additional _escapes_ are available in either character or non-raw string
|
||||
|
Loading…
Reference in New Issue
Block a user