|
|
@ -8,17 +8,17 @@
|
|
|
|
//! operations converts multiple future into a single future that returns the
|
|
|
|
//! operations converts multiple future into a single future that returns the
|
|
|
|
//! first output.
|
|
|
|
//! first output.
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! For operating on futures the following macros can be used:
|
|
|
|
//! For operating on futures the following functions can be used:
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! | Name | Return signature | When does it return? |
|
|
|
|
//! | Name | Return signature | When does it return? |
|
|
|
|
//! | --- | --- | --- |
|
|
|
|
//! | --- | --- | --- |
|
|
|
|
//! | [`future::join!`] | `(T1, T2)` | Wait for all to complete
|
|
|
|
//! | [`Future::join`] | `(T1, T2)` | Wait for all to complete
|
|
|
|
//! | [`Future::race`] | `T` | Return on first value
|
|
|
|
//! | [`Future::race`] | `T` | Return on first value
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! ## Fallible Futures Concurrency
|
|
|
|
//! ## Fallible Futures Concurrency
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! For operating on futures that return `Result` additional `try_` variants of
|
|
|
|
//! For operating on futures that return `Result` additional `try_` variants of
|
|
|
|
//! the macros mentioned before can be used. These macros are aware of `Result`,
|
|
|
|
//! the functions mentioned before can be used. These functions are aware of `Result`,
|
|
|
|
//! and will behave slightly differently from their base variants.
|
|
|
|
//! and will behave slightly differently from their base variants.
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! In the case of `try_join`, if any of the futures returns `Err` all
|
|
|
|
//! In the case of `try_join`, if any of the futures returns `Err` all
|
|
|
@ -30,19 +30,19 @@
|
|
|
|
//! means `try_race` will keep going until any one of the futures returns
|
|
|
|
//! means `try_race` will keep going until any one of the futures returns
|
|
|
|
//! `Ok`, or _all_ futures have returned `Err`.
|
|
|
|
//! `Ok`, or _all_ futures have returned `Err`.
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! However sometimes it can be useful to use the base variants of the macros
|
|
|
|
//! However sometimes it can be useful to use the base variants of the functions
|
|
|
|
//! even on futures that return `Result`. Here is an overview of operations that
|
|
|
|
//! even on futures that return `Result`. Here is an overview of operations that
|
|
|
|
//! work on `Result`, and their respective semantics:
|
|
|
|
//! work on `Result`, and their respective semantics:
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! | Name | Return signature | When does it return? |
|
|
|
|
//! | Name | Return signature | When does it return? |
|
|
|
|
//! | --- | --- | --- |
|
|
|
|
//! | --- | --- | --- |
|
|
|
|
//! | [`future::join!`] | `(Result<T, E>, Result<T, E>)` | Wait for all to complete
|
|
|
|
//! | [`Future::join`] | `(Result<T, E>, Result<T, E>)` | Wait for all to complete
|
|
|
|
//! | [`future::try_join!`] | `Result<(T1, T2), E>` | Return on first `Err`, wait for all to complete
|
|
|
|
//! | [`Future::try_join`] | `Result<(T1, T2), E>` | Return on first `Err`, wait for all to complete
|
|
|
|
//! | [`Future::race`] | `Result<T, E>` | Return on first value
|
|
|
|
//! | [`Future::race`] | `Result<T, E>` | Return on first value
|
|
|
|
//! | [`Future::try_race`] | `Result<T, E>` | Return on first `Ok`, reject on last Err
|
|
|
|
//! | [`Future::try_race`] | `Result<T, E>` | Return on first `Ok`, reject on last Err
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! [`future::join!`]: macro.join.html
|
|
|
|
//! [`Future::join`]: trait.Future.html#method.join
|
|
|
|
//! [`future::try_join!`]: macro.try_join.html
|
|
|
|
//! [`Future::try_join`]: trait.Future.html#method.try_join
|
|
|
|
//! [`Future::race`]: trait.Future.html#method.race
|
|
|
|
//! [`Future::race`]: trait.Future.html#method.race
|
|
|
|
//! [`Future::try_race`]: trait.Future.html#method.try_race
|
|
|
|
//! [`Future::try_race`]: trait.Future.html#method.try_race
|
|
|
|
|
|
|
|
|
|
|
|