|
10 | 10 | /// Takes each element in the stream: if it is an `Err`, no further
|
11 | 11 | /// elements are taken, and the `Err` is returned. Should no `Err`
|
12 | 12 | /// occur, a container with the values of each `Result` is returned.
|
| 13 | + /// |
| 14 | + /// # Examples |
| 15 | + /// |
| 16 | + /// ``` |
| 17 | + /// # fn main() { async_std::task::block_on(async { |
| 18 | + /// # |
| 19 | + /// use async_std::prelude::*; |
| 20 | + /// use async_std::stream; |
| 21 | + /// |
| 22 | + /// let v = stream::from_iter(vec![1, 2]); |
| 23 | + /// let res: Result<Vec<u32>, &'static str> = v.map(|x: u32| |
| 24 | + /// x.checked_add(1).ok_or("Overflow!") |
| 25 | + /// ).collect().await; |
| 26 | + /// assert_eq!(res, Ok(vec![2, 3])); |
| 27 | + /// # |
| 28 | + /// # }) } |
| 29 | + /// ``` |
13 | 30 | #[inline]
|
14 | 31 | fn from_stream<'a, S: IntoStream<Item = Result<T, E>> + 'a>(
|
15 | 32 | stream: S,
|
|
0 commit comments