From d0b750cd3328b8dc56cdd81323efafdc5fe5a4a1 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 7 Aug 2024 16:55:51 +0200 Subject: [PATCH] cargo clippy + fmt --- src/cli/database_command.rs | 12 ++++++------ src/cli/user_command.rs | 12 ++++++------ src/core/common.rs | 6 +++++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/cli/database_command.rs b/src/cli/database_command.rs index 52c8c3d..8ab90dd 100644 --- a/src/cli/database_command.rs +++ b/src/cli/database_command.rs @@ -149,14 +149,14 @@ pub async fn handle_command( mut conn: MySqlConnection, ) -> anyhow::Result<()> { let result = conn - .transaction(|mut txn| { + .transaction(|txn| { Box::pin(async move { match command { - DatabaseCommand::CreateDb(args) => create_databases(args, &mut txn).await, - DatabaseCommand::DropDb(args) => drop_databases(args, &mut txn).await, - DatabaseCommand::ListDb(args) => list_databases(args, &mut txn).await, - DatabaseCommand::ShowDbPerm(args) => show_databases(args, &mut txn).await, - DatabaseCommand::EditDbPerm(args) => edit_permissions(args, &mut txn).await, + DatabaseCommand::CreateDb(args) => create_databases(args, txn).await, + DatabaseCommand::DropDb(args) => drop_databases(args, txn).await, + DatabaseCommand::ListDb(args) => list_databases(args, txn).await, + DatabaseCommand::ShowDbPerm(args) => show_databases(args, txn).await, + DatabaseCommand::EditDbPerm(args) => edit_permissions(args, txn).await, } }) }) diff --git a/src/cli/user_command.rs b/src/cli/user_command.rs index 1cbb89c..6d86489 100644 --- a/src/cli/user_command.rs +++ b/src/cli/user_command.rs @@ -66,13 +66,13 @@ pub struct UserShowArgs { pub async fn handle_command(command: UserCommand, mut conn: MySqlConnection) -> anyhow::Result<()> { let result = conn - .transaction(|mut txn| { + .transaction(|txn| { Box::pin(async move { match command { - UserCommand::CreateUser(args) => create_users(args, &mut txn).await, - UserCommand::DropUser(args) => drop_users(args, &mut txn).await, - UserCommand::PasswdUser(args) => change_password_for_user(args, &mut txn).await, - UserCommand::ShowUser(args) => show_users(args, &mut txn).await, + UserCommand::CreateUser(args) => create_users(args, txn).await, + UserCommand::DropUser(args) => drop_users(args, txn).await, + UserCommand::PasswdUser(args) => change_password_for_user(args, txn).await, + UserCommand::ShowUser(args) => show_users(args, txn).await, } }) }) @@ -114,7 +114,7 @@ async fn create_users(args: UserCreateArgs, conn: &mut MySqlConnection) -> anyho ) .await?; } - println!(""); + println!(); } Ok(()) } diff --git a/src/core/common.rs b/src/core/common.rs index f67109e..d74cb0c 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -142,7 +142,11 @@ pub fn validate_ownership_by_user_prefix<'a>( } pub async fn close_database_connection(conn: MySqlConnection) { - if let Err(e) = conn.close().await.context("Failed to close connection properly") { + if let Err(e) = conn + .close() + .await + .context("Failed to close connection properly") + { eprintln!("{}", e); eprintln!("Ignoring..."); }