Comprehensive Rust(繁体中文) 20240663.1 async/await . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 63.2 Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 63.3 Runtimes . 作了事件迴圈(event loop),所以隱藏了很多關於 Promise 的處理細節。 63.1 async/await 從高層次的角度來看,非同步的 Rust 程式碼看起來很像「一般的」同步程式碼: use futures::executor::block_on; async fn count_to(count: i32) { for i in 1..=count { println!("Count is: • .await can only be used inside an async function (or block; these are introduced later). 63.2 Futures Future 是一種特徵,物件實作這種特徵時,代表作業或許尚未完成。Future 可供輪詢,而 poll 會傳回 Poll。 use std::pin::Pin; use std::task::Context;0 码力 | 356 页 | 1.41 MB | 1 年前3
共 1 条
- 1













