Rust 程序设计语言 简体中文版 1.85.0制权给运行时。我们可以使用 yield_now 函数来直接这么做。在示例 17-25 中,我们将所有的 sleep 调用替换为 yield_now。 文件名:src/main.rs let a = async { println!("'a' started."); slow("a", 30); trpl::yield_now() slow("a", 10); 400/562Rust 程序设计语言 简体中文版 trpl::yield_now().await; slow("a", 20); trpl::yield_now().await; println!("'a' finished."); }; slow("b", 75); trpl::yield_now().await; slow("b", 10); trpl::yield_now().await; slow("b", 15); trpl::yield_now().await; slow("b"0 码力 | 562 页 | 3.23 MB | 28 天前3
共 1 条
- 1













