File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -129,10 +129,17 @@ where
129
129
let mut cache = <<<C as LoadConnection >:: Row < ' _ , ' _ > as IntoOwnedRow <
130
130
<C as Connection >:: Backend ,
131
131
> >:: Cache as Default >:: default ( ) ;
132
- conn. load ( & query) . map ( |c| {
133
- c. map ( |row| row. map ( |r| IntoOwnedRow :: into_owned ( r, & mut cache) ) )
134
- . collect :: < Vec < QueryResult < O > > > ( )
135
- } )
132
+ let cursor = conn. load ( & query) ?;
133
+
134
+ let size_hint = cursor. size_hint ( ) ;
135
+ let mut out = Vec :: with_capacity ( size_hint. 1 . unwrap_or ( size_hint. 0 ) ) ;
136
+ // we use an explicit loop here to easily propagate possible errors
137
+ // as early as possible
138
+ for row in cursor {
139
+ out. push ( Ok ( IntoOwnedRow :: into_owned ( row?, & mut cache) ) ) ;
140
+ }
141
+
142
+ Ok ( out)
136
143
} )
137
144
. map_ok ( |rows| futures_util:: stream:: iter ( rows) . boxed ( ) )
138
145
. boxed ( )
You can’t perform that action at this time.
0 commit comments