Skip to content

Commit

Permalink
fix: actually use TryMapRow and MapRow in Query
Browse files Browse the repository at this point in the history
  • Loading branch information
mehcode committed Jul 3, 2020
1 parent 5d6516d commit 20229ea
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sqlx-core/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,22 @@ where
/// The [`query_as`](crate::query_as::query_as) method will construct a mapped query using
/// a [`FromRow`](crate::row::FromRow) implementation.
#[inline]
pub fn map<F, O>(self, f: F) -> Map<'q, DB, impl Fn(DB::Row) -> Result<O, Error>, A>
pub fn map<F, O>(self, f: F) -> Map<'q, DB, impl TryMapRow<DB, Output = O>, A>
where
F: Fn(DB::Row) -> O,
F: MapRow<DB, Output = O>,
O: Unpin,
{
self.try_map(move |row| Ok(f(row)))
self.try_map(MapRowAdapter(f))
}

/// Map each row in the result to another type.
///
/// The [`query_as`](crate::query_as::query_as) method will construct a mapped query using
/// a [`FromRow`](crate::row::FromRow) implementation.
#[inline]
pub fn try_map<F, O>(self, f: F) -> Map<'q, DB, F, A>
pub fn try_map<F>(self, f: F) -> Map<'q, DB, F, A>
where
F: Fn(DB::Row) -> Result<O, Error>,
F: TryMapRow<DB>,
{
Map {
inner: self,
Expand Down

0 comments on commit 20229ea

Please sign in to comment.