futures_concurrency/future/race/
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 future to complete.
9///
10/// Awaits multiple future at once, returning as soon as one completes. The
11/// other futures are cancelled.
12pub trait Race {
13    /// The resulting output type.
14    type Output;
15
16    /// Which kind of future are we turning this into?
17    type Future: Future<Output = Self::Output>;
18
19    /// Wait for the first future to complete.
20    ///
21    /// Awaits multiple futures at once, returning as soon as one completes. The
22    /// other futures are cancelled.
23    ///
24    /// This function returns a new future which polls all futures concurrently.
25    fn race(self) -> Self::Future;
26}