futures_concurrency/future/race_ok/
mod.rs

1use core::future::Future;
2
3pub(crate) mod array;
4pub(crate) mod tuple;
5#[cfg(feature = "alloc")]
6pub(crate) mod vec;
7
8/// Wait for the first successful future to complete.
9///
10/// Awaits multiple futures simultaneously, returning the output of the first
11/// future which completes. If no future completes successfully, returns an
12/// aggregate error of all failed futures.
13pub trait RaceOk {
14    /// The resulting output type.
15    type Output;
16
17    /// The resulting error type.
18    type Error;
19
20    /// Which kind of future are we turning this into?
21    type Future: Future<Output = Result<Self::Output, Self::Error>>;
22
23    /// Waits for the first successful future to complete.
24    fn race_ok(self) -> Self::Future;
25}