diff --git a/listings/ch17-async-await/listing-17-41/src/main.rs b/listings/ch17-async-await/listing-17-41/src/main.rs index f1f3d4b..7cdab2c 100644 --- a/listings/ch17-async-await/listing-17-41/src/main.rs +++ b/listings/ch17-async-await/listing-17-41/src/main.rs @@ -47,11 +47,11 @@ fn get_messages() -> impl Stream { fn get_intervals() -> impl Stream { let (tx, rx) = trpl::channel(); - // This is *not* `trpl::spawn` but `std::thread::spawn`! + // 这里 *不是* `trpl::spawn`,是 `std::thread::spawn`! thread::spawn(move || { let mut count = 0; loop { - // Likewise, this is *not* `trpl::sleep` but `std::thread::sleep`! + // 同样,这里 *不是* `trpl::sleep`,是 `std::thread::sleep`! thread::sleep(Duration::from_millis(1)); count += 1; diff --git a/src/ch17-05-traits-for-async.md b/src/ch17-05-traits-for-async.md index 51ddd81..5564d39 100644 --- a/src/ch17-05-traits-for-async.md +++ b/src/ch17-05-traits-for-async.md @@ -44,7 +44,7 @@ match page_title(url).poll() { None => println!("{url} had no title"), } Pending => { - // But what goes here? + // 但这里运行什么呢? } } ``` @@ -197,7 +197,7 @@ pub trait Future { -因此,如果 `String` 实现了 `!Unpin` 我们可以做一些非法的事,比如像图 17-9 这样在完全相同的内存位置将一个字符串替换为另一个字符串。这并不违反 `Pin` 的规则,因为 `String` 没有内部引用这使得它可以安全地移动!这是为何它实现了 `Unpin` 而不是 `!Unpin` 的原因。 +因此,如果 `String` 实现了 `!Unpin` 我们可以做一些非法的事,比如像图 17-9 这样在完全相同的内存位置将一个字符串替换为另一个字符串。这并不违反 `Pin` 的规则,因为 `String` 没有内部引用这使得它可以安全地移动!这是为何它实现了 `Unpin` 而不是 `!Unpin`。