| 1 | //! This module has extras that clash with names in [`futures-lite`], |
| 2 | //! which depends on us. |
| 3 | pub use crate::*; |
| 4 | |
| 5 | /// Zips two futures, waiting for both to complete. |
| 6 | /// |
| 7 | /// # Examples |
| 8 | /// |
| 9 | /// ``` |
| 10 | /// use futures_micro::prelude::zip; |
| 11 | /// |
| 12 | /// # futures_lite::future::block_on(async { |
| 13 | /// let a = async { 1 }; |
| 14 | /// let b = async { 2 }; |
| 15 | /// |
| 16 | /// assert_eq!(zip(a, b).await, (1, 2)); |
| 17 | /// # }) |
| 18 | /// ``` |
| 19 | pub fn zip<F1, F2>(f1: F1, f2: F2) -> Zip<F1, F2> |
| 20 | where |
| 21 | F1: Future, |
| 22 | F2: Future, |
| 23 | { |
| 24 | Zip::new(f1, f2) |
| 25 | } |
| 26 | |
| 27 | /// Returns the result of `left` or `right` future, preferring `left` if both are ready. |
| 28 | pub fn or<F1, F2>(future1: F1, future2: F2) -> Or<F1, F2> |
| 29 | where |
| 30 | F1: Future, |
| 31 | F2: Future, |
| 32 | { |
| 33 | Or { future1, future2 } |
| 34 | } |