pub fn select<T1, T2, F1, F2>(future1: F1, future2: F2) -> Select<F1, F2> ⓘ
Expand description
Returns the result of the future that completes first, preferring future1 if both are ready.
§Examples
use std::future;
use karyon_core::async_util::{select, Either};
async {
let fut1 = future::pending::<String>();
let fut2 = future::ready(0);
let res = select(fut1, fut2).await;
assert!(matches!(res, Either::Right(0)));
// ....
};