From 76034f058d322bf7891c05894994e24b29d2d3a3 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 27 Dec 2024 12:52:05 -0500 Subject: [PATCH] Cleaning up oauth providers conversion. (#5280) * Cleaning up oauth providers conversion. * Use into_iter --- crates/db_schema/src/impls/oauth_provider.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/db_schema/src/impls/oauth_provider.rs b/crates/db_schema/src/impls/oauth_provider.rs index 9d7e791e7..7665ba050 100644 --- a/crates/db_schema/src/impls/oauth_provider.rs +++ b/crates/db_schema/src/impls/oauth_provider.rs @@ -55,13 +55,11 @@ impl OAuthProvider { pub fn convert_providers_to_public( oauth_providers: Vec, ) -> Vec { - let mut result = Vec::::new(); - for oauth_provider in &oauth_providers { - if oauth_provider.enabled { - result.push(PublicOAuthProvider(oauth_provider.clone())); - } - } - result + oauth_providers + .into_iter() + .filter(|x| x.enabled) + .map(PublicOAuthProvider) + .collect() } pub async fn get_all_public(pool: &mut DbPool<'_>) -> Result, Error> {