From b6a0df58417012d82404ffadf85328f7c183187c Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Mon, 6 Nov 2023 11:15:51 -0800 Subject: [PATCH] better scoping and such --- src/management.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/management.rs b/src/management.rs index 11292c0..def59f6 100644 --- a/src/management.rs +++ b/src/management.rs @@ -16,15 +16,17 @@ async fn home() -> impl IntoResponse { } async fn dancers(State(state): State) -> impl IntoResponse { - use cm_lib::schema::dancers::dsl::*; + let dancers = { + use cm_lib::schema::dancers::dsl::*; - let mut conn = state.connection.get().await.unwrap(); + let mut conn = state.connection.get().await.unwrap(); - let dancers_vec = dancers - .select(Dancer::as_select()) - .load(&mut conn) - .await - .unwrap(); + dancers + .select(Dancer::as_select()) + .load(&mut conn) + .await + .unwrap() + }; - render!(crate::templates::dancers_html, dancers_vec) + render!(crate::templates::dancers_html, dancers) }