Function cros_async::select3
source · pub async fn select3<F1: Future + Unpin, F2: Future + Unpin, F3: Future + Unpin>(
f1: F1,
f2: F2,
f3: F3
) -> (SelectResult<F1>, SelectResult<F2>, SelectResult<F3>)
Expand description
Creates a combinator that runs the three given futures until one or more completes, returning a tuple containing the result of the finished future(s) and the still pending future(s).
§Example
use cros_async::{SelectResult, select3, block_on};
use futures::future::pending;
use futures::pin_mut;
let first = async {4};
let second = async {let () = pending().await;};
let third = async {5};
pin_mut!(first);
pin_mut!(second);
pin_mut!(third);
match block_on(select3(first, second, third)) {
(SelectResult::Finished(4),
SelectResult::Pending(_second),
SelectResult::Finished(5)) => (),
_ => panic!("Select didn't return the futures"),
};