File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -707,6 +707,33 @@ let py = d"
707
707
// OK
708
708
```
709
709
710
+ Both outputs will not contain a newline at the end, since the literal newline is stripped.
711
+
712
+ If you'd like to have a trailing newline, you can insert a literal newline at the end:
713
+
714
+ ``` rust
715
+ let py = d "
716
+ def hello():
717
+ print('Hello, world!')
718
+
719
+ hello()
720
+
721
+ " ;
722
+ // OK
723
+ ```
724
+
725
+ You can also use an escaped newline. This is fine, because the string still ends with a literal newline (which cannot be escaped):
726
+
727
+ ``` rust
728
+ let py = d "
729
+ def hello():
730
+ print('Hello, world!')
731
+
732
+ hello()\ n
733
+ " ;
734
+ // OK
735
+ ```
736
+
710
737
Benefits the above rules bring include:
711
738
712
739
- The above rules make all dedented string literals you'll find in Rust consistent.
You can’t perform that action at this time.
0 commit comments