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: text/3830-dedented-string-literals.md
+9-4Lines changed: 9 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -806,9 +806,14 @@ Note: **Literal newlines** (*not* escaped newlines: `\n`) are represented with `
806
806
- Only the amount equal to the closing indentation, or less, will be removed.
807
807
- Never more than the line actually has.
808
808
809
-
### Treatment of literal escapes: `\t`, `\r` and `\n`
809
+
### Treatment of literal whitespace escapes: `\t`, `\r` and `\n`
810
810
811
-
`\t` is allowed in the line which contains the closing quote. Writing it is equivalent to inserting a literal tab.
811
+
#### On the line containing the closing quote
812
+
813
+
- Only whitespace is allowed before the closing quote.
814
+
- Escapes are not permitted even if they are escapes for whitespace (e.g. a tab escape `\t`), because escapes are processed after dedenting, so they are not yet whitespace when the line with the closing quote is processed.
815
+
816
+
#### In the content of the string
812
817
813
818
The escaped characters `\t`, `\r` and `\n` are treated as regular characters for the purposes of dedentation.
814
819
@@ -820,7 +825,7 @@ println!(
820
825
\ta
821
826
\tb
822
827
\tc
823
-
\t"
828
+
"// the indent here is a tab
824
829
);
825
830
```
826
831
@@ -832,7 +837,7 @@ Prints, with each indentation being **1 tab**:
832
837
c
833
838
```
834
839
835
-
The indentation is not removed, because common indentation in this example is 0.
840
+
The indentation is not removed, because common indentation in this example is 0. (closing indentation is 1 tab).
836
841
837
842
Escaped characters at the beginning of the string are interpreted as any other character, and **not** whitespace.
0 commit comments