You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/tokens.md
+6-22
Original file line number
Diff line number
Diff line change
@@ -156,30 +156,13 @@ A _string literal_ is a sequence of any Unicode characters enclosed within two
156
156
`U+0022` (double-quote) characters, with the exception of `U+0022` itself,
157
157
which must be _escaped_ by a preceding `U+005C` character (`\`).
158
158
159
-
Line-breaks are allowed in string literals. A line-break is either a newline
160
-
(`U+000A`) or a pair of carriage return and newline (`U+000D`, `U+000A`). Both
161
-
byte sequences are normally translated to `U+000A`, but as a special exception,
162
-
when an unescaped `U+005C` character (`\`) occurs immediately before a line
163
-
break, then the line break character(s), and all immediately following
164
-
`` (`U+0020`), `\t` (`U+0009`), `\n` (`U+000A`) and `\r` (`U+0000D`) characters
165
-
are ignored. Thus `a`, `b` and `c` are equal:
159
+
Line-breaks are allowed in string literals.
160
+
A line-break is either a newline (`U+000A`) or a pair of carriage return and newline (`U+000D`, `U+000A`).
161
+
Both byte sequences are translated to `U+000A`.
166
162
167
-
```rust
168
-
leta="foobar";
169
-
letb="foo\
170
-
bar";
171
-
letc="foo\
172
-
173
-
bar";
174
-
175
-
assert_eq!(a, b);
176
-
assert_eq!(b, c);
177
-
```
163
+
When an unescaped `U+005C` character (`\`) occurs immediately before a line break, the line break does not appear in the string represented by the token.
164
+
See [String continuation escapes] for details.
178
165
179
-
> Note: Rust skipping additional newlines (like in example `c`) is potentially confusing and
180
-
> unexpected. This behavior may be adjusted in the future. Until a decision is made, it is
181
-
> recommended to avoid relying on this, i.e. skipping multiple newlines with line continuations.
182
-
> See [this issue](https://github.com/rust-lang/reference/pull/1042) for more information.
183
166
184
167
#### Character escapes
185
168
@@ -808,6 +791,7 @@ Similarly the `r`, `b`, `br`, `c`, and `cr` prefixes used in raw string literals
0 commit comments