@@ -3,7 +3,9 @@ use crate::stream::{FromStream, IntoStream, Stream};
33use std:: pin:: Pin ;
44
55impl < 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+ {
79 /// Takes each element in the stream: if it is an `Err`, no further
810 /// elements are taken, and the `Err` is returned. Should no `Err`
911 /// 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>
2224 // Using `scan` here because it is able to stop the stream early
2325 // if a failure occurs
2426 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 ;
3540
3641 match found_error {
3742 Some ( err) => Err ( err) ,
@@ -40,4 +45,3 @@ impl<T: Send, E: Send, V> FromStream<Result<T, E>> for Result<V, E>
4045 } ) )
4146 }
4247}
43-
0 commit comments