知识卡片
普通字面量的转义和续行
字符串用双引号,单个字符用单引号。常用的 \n、\t 分别写出换行和制表符,也可用 Unicode 码点写字面量,如 \u{CA0} 对应 ಠ。普通字符串跨行时会保留换行和缩进。若需要把长源码折行而让结果保持在同一行,在行尾放反斜杠,下一行的前导空白会一起被舍弃。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Fundamental Types 字面量中的转义、多行与原样文本 · 查看原书依据
If one line of a string ends with a backslash, then the newline character and the leading whitespace on the next line are dropped:
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第02章《Fundamental Types》|字面量中的转义、多行与原样文本,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch02.xhtml#string-and-character-literals`
- 结论依据:原文包含字符转义表和两段不同的跨行例子,由此区分文本换行和源码续行。
- 原始内容:If one line of a string ends with a backslash, then the newline character and the leading whitespace on the next line are dropped: