pub trait Race {
type Output;
type Future: Future<Output = Self::Output>;
// Required method
fn race(self) -> Self::Future;
}Expand description
Wait for the first future to complete.
Awaits multiple future at once, returning as soon as one completes. The other futures are cancelled.
Required Associated Types§
Required Methods§
Sourcefn race(self) -> Self::Future
fn race(self) -> Self::Future
Wait for the first future to complete.
Awaits multiple futures at once, returning as soon as one completes. The other futures are cancelled.
This function returns a new future which polls all futures concurrently.
§Panics
This method will panic if the collection is empty (for Vec and array
implementations) since there would be no future to race.