Remove Row.

This commit is contained in:
LukeMathWalker 2021-08-01 15:17:47 +01:00
parent d54f33858d
commit 9e75751b6b

View file

@ -79,12 +79,7 @@ struct ConfirmedSubscriber {
async fn get_confirmed_subscribers(
pool: &PgPool,
) -> Result<Vec<Result<ConfirmedSubscriber, anyhow::Error>>, 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)
}