-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I think the following race_with_index function would be very useful:
pub trait Race {
type Output;
type Future: Future<Output = Self::Output>;
fn race(self) -> Self::Future;
// New method:
fn race_with_index(self) -> impl Future<Output = (usize, Self::Output)>;
}Usage:
let (i, result) = (fut_1, fut_2).race().await;
println!("Future {i} won the race with result {result}");A similar function should probably also be add to RaceOk.
Metadata
Metadata
Assignees
Labels
No labels