4242 Impl : Send ,
4343 {
4444 let mut futures = FuturesUnordered :: new ( ) ;
45- let mut is_abort = false ;
4645
4746 // Populate `futures` with all the roots, `root_nodes` isn't required to be `Send`, so this
4847 // has to happen outside of the future. We could require `root_nodes` to be `Send` in the
@@ -62,18 +61,11 @@ where
6261 VisitControlFlow :: Exclude => {
6362 // do nothing
6463 }
65- VisitControlFlow :: Abort => {
66- // this must be returned inside the `async` block below so that it's part of the
67- // returned future
68- is_abort = true ;
69- }
7064 }
7165 }
7266
7367 async move {
74- if is_abort {
75- return GraphTraversalResult :: Aborted ;
76- }
68+ let mut result = Ok ( ( ) ) ;
7769 loop {
7870 match futures. next ( ) . await {
7971 Some ( ( parent_node, span, Ok ( edges) ) ) => {
@@ -94,17 +86,14 @@ where
9486 VisitControlFlow :: Exclude => {
9587 // do nothing
9688 }
97- VisitControlFlow :: Abort => {
98- return GraphTraversalResult :: Aborted ;
99- }
10089 }
10190 }
10291 }
10392 Some ( ( _, _, Err ( err) ) ) => {
104- return GraphTraversalResult :: Completed ( Err ( err) ) ;
93+ result = Err ( err) ;
10594 }
10695 None => {
107- return GraphTraversalResult :: Completed ( Ok ( self ) ) ;
96+ return GraphTraversalResult :: Completed ( result . map ( | ( ) | self ) ) ;
10897 }
10998 }
11099 }
@@ -114,14 +103,12 @@ where
114103
115104pub enum GraphTraversalResult < Completed > {
116105 Completed ( Completed ) ,
117- Aborted ,
118106}
119107
120108impl < Completed > GraphTraversalResult < Completed > {
121109 pub fn completed ( self ) -> Completed {
122110 match self {
123111 GraphTraversalResult :: Completed ( completed) => completed,
124- GraphTraversalResult :: Aborted => panic ! ( "Graph traversal was aborted" ) ,
125112 }
126113 }
127114}
0 commit comments