1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-07 18:16:15 +02:00

zh-Hans: Translation for src/why-rust/compile-time.md (#737)

* zh-Hans: Translation for src/why-rust/compile-time.md

---------

Co-authored-by: wnghl <wnghilin@gmail.com>
This commit is contained in:
Yulin Shen 2023-05-31 17:30:34 +08:00 committed by GitHub
parent 4f2263a785
commit 2e9e166f65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,7 @@ msgstr "为什么选择 Rust?"
#: src/SUMMARY.md:23 #: src/SUMMARY.md:23
msgid "Compile Time Guarantees" msgid "Compile Time Guarantees"
msgstr "" msgstr "编译期保障"
#: src/SUMMARY.md:24 #: src/SUMMARY.md:24
msgid "Runtime Guarantees" msgid "Runtime Guarantees"
@ -2234,11 +2234,11 @@ msgstr ""
#: src/why-rust/compile-time.md:1 #: src/why-rust/compile-time.md:1
msgid "# Compile Time Guarantees" msgid "# Compile Time Guarantees"
msgstr "" msgstr "# 编译期保障"
#: src/why-rust/compile-time.md:3 #: src/why-rust/compile-time.md:3
msgid "Static memory management at compile time:" msgid "Static memory management at compile time:"
msgstr "" msgstr "编译期静态内存管理:"
#: src/why-rust/compile-time.md:5 #: src/why-rust/compile-time.md:5
msgid "" msgid ""
@ -2251,12 +2251,21 @@ msgid ""
"* No data races between threads.\n" "* No data races between threads.\n"
"* No iterator invalidation." "* No iterator invalidation."
msgstr "" msgstr ""
"* 不存在未初始化的变量。\n"
"* 不存在内存泄漏(_通常情况下_,见注释)。\n"
"* 不存在“双重释放”。\n"
"* 不存在“释放后使用”。\n"
"* 不存在 `NULL` 指针。\n"
"* 不存在被遗忘的互斥锁。\n"
"* 不存在线程之间的数据竞争。\n"
"* 不存在迭代器失效。"
#: src/why-rust/compile-time.md:16 #: src/why-rust/compile-time.md:16
msgid "" msgid ""
"It is possible to produce memory leaks in (safe) Rust. Some examples\n" "It is possible to produce memory leaks in (safe) Rust. Some examples\n"
"are:" "are:"
msgstr "" msgstr ""
"在(安全的)Rust 中也有可能产生内存泄漏。例如:"
#: src/why-rust/compile-time.md:19 #: src/why-rust/compile-time.md:19
msgid "" msgid ""
@ -2269,12 +2278,17 @@ msgid ""
"* In fact, some will consider infinitely populating a collection a memory\n" "* In fact, some will consider infinitely populating a collection a memory\n"
" leak and Rust does not protect from those." " leak and Rust does not protect from those."
msgstr "" msgstr ""
"* 可以使用 [`Box::leak`] 来泄漏一个指针。该方法可以用于得到在运行时决定大小和初始化的静态变量\n"
"* 可以使用 [`std::mem::forget`] 来让编译器“忘记”一个值(即其析构函数不会被执行)。\n"
"* 可以使用 `Rc` 或 `Arc` 意外创建一个循环引用([reference cycle])。\n"
"* 实际上,有人认为无限填充一个集合也是一种内存泄漏,Rust 对此没有保护。"
#: src/why-rust/compile-time.md:28 #: src/why-rust/compile-time.md:28
msgid "" msgid ""
"For the purpose of this course, \"No memory leaks\" should be understood\n" "For the purpose of this course, \"No memory leaks\" should be understood\n"
"as \"Pretty much no *accidental* memory leaks\"." "as \"Pretty much no *accidental* memory leaks\"."
msgstr "" msgstr ""
"就本课程而言,“不存在内存泄漏”应理解为“几乎没有 *意外* 内存泄漏”。"
#: src/why-rust/runtime.md:1 #: src/why-rust/runtime.md:1
msgid "# Runtime Guarantees" msgid "# Runtime Guarantees"