We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0ed0d63 commit 5d5064bCopy full SHA for 5d5064b
src/result/from_stream.rs
@@ -10,6 +10,23 @@ where
10
/// Takes each element in the stream: if it is an `Err`, no further
11
/// elements are taken, and the `Err` is returned. Should no `Err`
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
30
#[inline]
31
fn from_stream<'a, S: IntoStream<Item = Result<T, E>> + 'a>(
32
stream: S,
0 commit comments