From dd9affd2b247b5df4042b975f8c7cfab59e26c75 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 22 Aug 2022 16:40:29 +0200 Subject: Fix `get_client()` for use `match-case` only once --- server/src/db.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'server/src/db.rs') diff --git a/server/src/db.rs b/server/src/db.rs index 8cc4d1f..b08c38c 100644 --- a/server/src/db.rs +++ b/server/src/db.rs @@ -15,6 +15,9 @@ pub async fn setup() -> Result<(), AppError> { Ok(()) } -pub unsafe fn get_client() -> Option<&'static PgPool> { - CONNECTION.as_ref() +pub unsafe fn get_client() -> &'static PgPool { + match &CONNECTION { + Some(client) => &client, + None => panic!("Connection not established!"), + } } -- cgit v1.2.3-18-g5258