mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-17 21:27:56 +02:00
zh-CN: Translation for src/basic-syntax/scopes-shadowing.md (#793)
* zh-CN: Translation for src/basic-syntax/scopes-shadowing.md * Change the translation for shadowing from 遮蔽 to 隐藏 * Address superwhd's comments
This commit is contained in:
parent
5d56a529da
commit
935456fccb
38
po/zh-CN.po
38
po/zh-CN.po
@ -2113,7 +2113,7 @@ msgstr ""
|
||||
"* Rust 非常像 C/C++/Java 等其他传统语言。它是指令式语言(而非函数式),而且除非绝对必要,它不会尝试重新发明新的概念。\n"
|
||||
"* Rust 是一种现代编程语言,它完全支持 Unicode 等特性。\n"
|
||||
"* 在需要处理可变数量的参数的情况下,Rust 使用宏(没有函数[重载](basic-syntax/functions-interlude.md))。\n"
|
||||
"* 宏是“卫生的”意味着它们不会意外地捕获它们所在作用域中的标识符。Rust 的宏实际上只是[部分卫生](https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene.html)"
|
||||
"* 宏是“卫生的”意味着它们不会意外地捕获它们所在作用域中的标识符。Rust 的宏实际上只是[部分卫生](https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene.html)。"
|
||||
|
||||
|
||||
#: src/hello-world/small-example.md:1
|
||||
@ -2709,7 +2709,7 @@ msgstr ""
|
||||
"类型,\n"
|
||||
" 也是这种类型的唯一值——也就是说它的类型和它的"
|
||||
" 值都被表示为 `()`。它通常用于表示,比如,一个"
|
||||
" 函数或表达式没有返回值,我们会在后续的幻灯片种见到这种用法。"
|
||||
" 函数或表达式没有返回值,我们会在后续的幻灯片种见到这种用法。"
|
||||
" \n"
|
||||
" * 你可以将其理解为你可能在其他编程语言中比较熟悉的 \n"
|
||||
" `void` 类型"
|
||||
@ -3746,7 +3746,7 @@ msgstr ""
|
||||
|
||||
#: src/basic-syntax/scopes-shadowing.md:1
|
||||
msgid "# Scopes and Shadowing"
|
||||
msgstr ""
|
||||
msgstr "# 作用域和隐藏 (Shadowing) "
|
||||
|
||||
#: src/basic-syntax/scopes-shadowing.md:3
|
||||
msgid ""
|
||||
@ -3754,6 +3754,8 @@ msgid ""
|
||||
"the\n"
|
||||
"same scope:"
|
||||
msgstr ""
|
||||
"你可以隐藏变量,位于外部作用域的变量和\n"
|
||||
"相同作用域的变量都可以:"
|
||||
|
||||
#: src/basic-syntax/scopes-shadowing.md:6
|
||||
msgid ""
|
||||
@ -3774,6 +3776,22 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"fn main() {\n"
|
||||
" let a = 10;\n"
|
||||
" println!(\"before: {a}\");\n"
|
||||
"\n"
|
||||
" {\n"
|
||||
" let a = \"hello\";\n"
|
||||
" println!(\"inner scope: {a}\");\n"
|
||||
"\n"
|
||||
" let a = true;\n"
|
||||
" println!(\"shadowed in inner scope: {a}\");\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" println!(\"after: {a}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/basic-syntax/scopes-shadowing.md:25
|
||||
msgid ""
|
||||
@ -3787,6 +3805,12 @@ msgid ""
|
||||
"locations when shadowing an immutable variable in a scope, even if the type "
|
||||
"does not change."
|
||||
msgstr ""
|
||||
"* 定义: 隐藏和变更 (mutation) 不同,因为在隐藏之后,两个变量都会同时存在于内存的不同位置中。"
|
||||
"在同一个名字下的两个变量都是可以被使用的,但是你在代码的哪里使用会最终决定你使用哪一个变量。\n"
|
||||
"* 一个隐藏变量可以具有不同的类型。\n"
|
||||
"* 隐藏起初看起来会有些晦涩,但是它很便于存 `.unwrap()` 之后的得到的值。\n"
|
||||
"* 以下代码说明了为什么在作用域内隐藏一个不可变的变量时,即使是在变量类型没有改变的情况下,"
|
||||
"编译器也不能简单地重复利用之前的内存位置。"
|
||||
|
||||
#: src/basic-syntax/scopes-shadowing.md:30
|
||||
msgid ""
|
||||
@ -3799,6 +3823,14 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"fn main() {\n"
|
||||
" let a = 1;\n"
|
||||
" let b = &a;\n"
|
||||
" let a = a + 1;\n"
|
||||
" println!(\"{a} {b}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/memory-management.md:1
|
||||
msgid "# Memory Management"
|
||||
|
Loading…
x
Reference in New Issue
Block a user