pub fn select_two<F1, F2, T1, T2>(future1: F1, future2: F2) -> SelectTwo<F1, F2> ⓘExpand description
Select from two futures, returning the first that completes 从两个future中选择,返回第一个完成的
§Example / 示例
ⓘ
use hiver_runtime::select::{select_two, SelectTwo};
use hiver_runtime::time::{sleep, Duration};
async fn example() {
let sleep1 = sleep(Duration::from_millis(100));
let sleep2 = sleep(Duration::from_millis(200));
match select_two(sleep1, sleep2).await {
SelectTwo::First(_) => println!("First completed"),
SelectTwo::Second(_) => println!("Second completed"),
}
}