|
1 | | -use crate::stream::{FromStream, IntoStream, Stream}; |
| 1 | +// use crate::stream::{FromStream, IntoStream, Stream}; |
2 | 2 |
|
3 | | -use std::pin::Pin; |
| 3 | +// use std::pin::Pin; |
4 | 4 |
|
5 | | -impl<T: Send, E: Send, V> FromStream<Result<T, E>> for Result<V, E> |
6 | | -where |
7 | | - V: FromStream<T>, |
8 | | -{ |
9 | | - /// Takes each element in the stream: if it is an `Err`, no further |
10 | | - /// elements are taken, and the `Err` is returned. Should no `Err` |
11 | | - /// occur, a container with the values of each `Result` is returned. |
12 | | - #[inline] |
13 | | - fn from_stream<'a, S: IntoStream<Item = Result<T, E>>>( |
14 | | - stream: S, |
15 | | - ) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>> |
16 | | - where |
17 | | - <S as IntoStream>::IntoStream: Send + 'a, |
18 | | - { |
19 | | - let stream = stream.into_stream(); |
| 5 | +// impl<T: Send, E: Send, V> FromStream<Result<T, E>> for Result<V, E> |
| 6 | +// where |
| 7 | +// V: FromStream<T>, |
| 8 | +// { |
| 9 | +// /// Takes each element in the stream: if it is an `Err`, no further |
| 10 | +// /// elements are taken, and the `Err` is returned. Should no `Err` |
| 11 | +// /// occur, a container with the values of each `Result` is returned. |
| 12 | +// #[inline] |
| 13 | +// fn from_stream<'a, S: IntoStream<Item = Result<T, E>>>( |
| 14 | +// stream: S, |
| 15 | +// ) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>> |
| 16 | +// where |
| 17 | +// <S as IntoStream>::IntoStream: Send + 'a, |
| 18 | +// { |
| 19 | +// let stream = stream.into_stream(); |
20 | 20 |
|
21 | | - Pin::from(Box::new(async move { |
22 | | - pin_utils::pin_mut!(stream); |
| 21 | +// Pin::from(Box::new(async move { |
| 22 | +// pin_utils::pin_mut!(stream); |
23 | 23 |
|
24 | | - // Using `scan` here because it is able to stop the stream early |
25 | | - // if a failure occurs |
26 | | - let mut found_error = None; |
27 | | - let out: V = stream |
28 | | - .scan((), |_, elem| { |
29 | | - match elem { |
30 | | - Ok(elem) => Some(elem), |
31 | | - Err(err) => { |
32 | | - found_error = Some(err); |
33 | | - // Stop processing the stream on error |
34 | | - None |
35 | | - } |
36 | | - } |
37 | | - }) |
38 | | - .collect() |
39 | | - .await; |
| 24 | +// // Using `scan` here because it is able to stop the stream early |
| 25 | +// // if a failure occurs |
| 26 | +// let mut found_error = None; |
| 27 | +// let out: V = stream |
| 28 | +// .scan((), |_, elem| { |
| 29 | +// match elem { |
| 30 | +// Ok(elem) => Some(elem), |
| 31 | +// Err(err) => { |
| 32 | +// found_error = Some(err); |
| 33 | +// // Stop processing the stream on error |
| 34 | +// None |
| 35 | +// } |
| 36 | +// } |
| 37 | +// }) |
| 38 | +// .collect() |
| 39 | +// .await; |
40 | 40 |
|
41 | | - match found_error { |
42 | | - Some(err) => Err(err), |
43 | | - None => Ok(out), |
44 | | - } |
45 | | - })) |
46 | | - } |
47 | | -} |
| 41 | +// match found_error { |
| 42 | +// Some(err) => Err(err), |
| 43 | +// None => Ok(out), |
| 44 | +// } |
| 45 | +// })) |
| 46 | +// } |
| 47 | +// } |
0 commit comments