make the stream returned from Map::fetch() Unpin

closes #244
This commit is contained in:
Austin Bonander 2020-04-10 23:19:15 -07:00 committed by Ryan Leckey
parent 90fd35745c
commit 80eb2cc7d2

View File

@ -146,20 +146,20 @@ where
pub fn fetch<'e: 'q, E>( pub fn fetch<'e: 'q, E>(
mut self, mut self,
executor: E, executor: E,
) -> impl Stream<Item = crate::Result<F::Output>> + 'e ) -> impl Stream<Item = crate::Result<F::Output>> + Unpin + 'e
where where
'q: 'e, 'q: 'e,
E: RefExecutor<'e, Database = DB> + 'e, E: RefExecutor<'e, Database = DB> + 'e,
F: 'e, F: 'e,
F::Output: 'e, F::Output: 'e,
{ {
try_stream! { Box::pin(try_stream! {
let mut cursor = executor.fetch_by_ref(self.query); let mut cursor = executor.fetch_by_ref(self.query);
while let Some(next) = cursor.next().await? { while let Some(next) = cursor.next().await? {
let mapped = self.mapper.try_map_row(next)?; let mapped = self.mapper.try_map_row(next)?;
yield mapped; yield mapped;
} }
} })
} }
/// Get the first row in the result /// Get the first row in the result