mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-02-04 18:36:01 +02:00
zh-Hans: Translation for src/async/async-await.md (#720)
This commit is contained in:
parent
aaca44f62b
commit
ebbc7501fb
@ -15147,7 +15147,7 @@ msgstr ""
|
||||
msgid ""
|
||||
"At a high level, async Rust code looks very much like \"normal\" sequential "
|
||||
"code:"
|
||||
msgstr ""
|
||||
msgstr "从高层次上看,异步 Rust 代码与“正常”的顺序代码非常类似:"
|
||||
|
||||
#: src/async/async-await.md:5
|
||||
msgid ""
|
||||
@ -15198,6 +15198,20 @@ msgid ""
|
||||
"* `.await` can only be used inside an `async` function (or block; these are\n"
|
||||
" introduced later). "
|
||||
msgstr ""
|
||||
"* 请注意,这只是一个简单的示例,用于展示语法。其中没有长时间运行的操作或任何真正的并发!\n"
|
||||
"\n"
|
||||
"* 异步调用的返回类型是什么?\n"
|
||||
" * 在 `main` 中使用 `let future: () = async_main(10);` 来查看类型。\n"
|
||||
"\n"
|
||||
"* \"async\" 关键字是语法糖。编译器会将返回类型替换为 future。\n"
|
||||
"\n"
|
||||
"* 你不能将 `main` 声明为异步函数,除非在编译器中加入额外的指令来告诉它如何使用返回的 future。\n"
|
||||
"\n"
|
||||
"* 你需要一个执行器来运行异步代码。`block_on`会阻塞当前线程,直到提供的future完成为止。 \n"
|
||||
"\n"
|
||||
"* `.await` 会异步地等待另一个操作的完成。与 `block_on` 不同,`.await` 不会阻塞当前线程。\n"
|
||||
"\n"
|
||||
"* `.await` 只能在 `async` 函数(或块,这些稍后会介绍)中使用。 "
|
||||
|
||||
#: src/async/futures.md:1
|
||||
msgid "# Futures"
|
||||
|
Loading…
x
Reference in New Issue
Block a user