@@ -3,7 +3,9 @@ use crate::stream::{FromStream, IntoStream, Stream};
3
3
use std:: pin:: Pin ;
4
4
5
5
impl < T : Send , E : Send , V > FromStream < Result < T , E > > for Result < V , E >
6
- where V : FromStream < T > {
6
+ where
7
+ V : FromStream < T > ,
8
+ {
7
9
/// Takes each element in the stream: if it is an `Err`, no further
8
10
/// elements are taken, and the `Err` is returned. Should no `Err`
9
11
/// occur, a container with the values of each `Result` is returned.
@@ -22,16 +24,19 @@ impl<T: Send, E: Send, V> FromStream<Result<T, E>> for Result<V, E>
22
24
// Using `scan` here because it is able to stop the stream early
23
25
// if a failure occurs
24
26
let mut found_error = None ;
25
- let out: V = stream. scan ( ( ) , |_, elem| {
26
- match elem {
27
- Ok ( elem) => Some ( elem) ,
28
- Err ( err) => {
29
- found_error = Some ( err) ;
30
- // Stop processing the stream on error
31
- None
32
- } ,
33
- }
34
- } ) . collect ( ) . await ;
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 ;
35
40
36
41
match found_error {
37
42
Some ( err) => Err ( err) ,
@@ -40,4 +45,3 @@ impl<T: Send, E: Send, V> FromStream<Result<T, E>> for Result<V, E>
40
45
} ) )
41
46
}
42
47
}
43
-
0 commit comments