From 9e75751b6b364aaccf81f39a08251d093e0e6ef8 Mon Sep 17 00:00:00 2001 From: LukeMathWalker Date: Sun, 1 Aug 2021 15:17:47 +0100 Subject: [PATCH] Remove `Row`. --- src/routes/newsletters.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/routes/newsletters.rs b/src/routes/newsletters.rs index 780b5c3..2a3be0c 100644 --- a/src/routes/newsletters.rs +++ b/src/routes/newsletters.rs @@ -79,12 +79,7 @@ struct ConfirmedSubscriber { async fn get_confirmed_subscribers( pool: &PgPool, ) -> Result>, anyhow::Error> { - struct Row { - email: String, - } - - let rows = sqlx::query_as!( - Row, + let confirmed_subscribers = sqlx::query!( r#" SELECT email FROM subscriptions @@ -92,13 +87,12 @@ async fn get_confirmed_subscribers( "#, ) .fetch_all(pool) - .await?; - let confirmed_subscribers = rows - .into_iter() - .map(|r| match SubscriberEmail::parse(r.email) { - Ok(email) => Ok(ConfirmedSubscriber { email }), - Err(error) => Err(anyhow::anyhow!(error)), - }) - .collect(); + .await? + .into_iter() + .map(|r| match SubscriberEmail::parse(r.email) { + Ok(email) => Ok(ConfirmedSubscriber { email }), + Err(error) => Err(anyhow::anyhow!(error)), + }) + .collect(); Ok(confirmed_subscribers) }