Rust 程序设计语言 简体中文版 1.85.0
run 函数返回。这正是 trpl::run 函数的全部意义:它允许你 选择 在何处阻塞一部分异步代码,也就是在何 处进行同步和异步代码的转换。这正是在大部分运行时中 run 实际上被命名为 block_on 的原因。 请注意这个示例中的两个地方:首先,消息立刻就会到达!其次,虽然我们使用了 future,但 是这里还没有并发。示例中的所有事情都是顺序发生的,就像没涉及到 future 时一样。 String::from("from"), ... | 19 | | } 20 | | }; | |_________- the expected `async` block 21 | 22 | let rx_fut = async { | ______________________- 23 | | while let found `async` block ... 43 | let futures = vec![tx1_fut, rx_fut, tx_fut]; | ^^^^^^ expected `async` block, found a different `async` block | 393/562Rust0 码力 | 562 页 | 3.23 MB | 8 天前3
共 1 条
- 1