Merge pull request #888 from qwer252/main

pull/892/head
KaiserY 1 week ago committed by GitHub
commit aabafa0653
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -47,11 +47,11 @@ fn get_messages() -> impl Stream<Item = String> {
fn get_intervals() -> impl Stream<Item = u32> {
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;

@ -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 {
</figure>
因此,如果 `String` 实现了 `!Unpin` 我们可以做一些非法的事,比如像图 17-9 这样在完全相同的内存位置将一个字符串替换为另一个字符串。这并不违反 `Pin` 的规则,因为 `String` 没有内部引用这使得它可以安全地移动!这是为何它实现了 `Unpin` 而不是 `!Unpin` 的原因
因此,如果 `String` 实现了 `!Unpin` 我们可以做一些非法的事,比如像图 17-9 这样在完全相同的内存位置将一个字符串替换为另一个字符串。这并不违反 `Pin` 的规则,因为 `String` 没有内部引用这使得它可以安全地移动!这是为何它实现了 `Unpin` 而不是 `!Unpin`
<figure>

Loading…
Cancel
Save