From 64efad6035204e75fff2afd8a38a949687f1ae69 Mon Sep 17 00:00:00 2001 From: Joey de Waal Date: Thu, 26 Sep 2024 11:42:22 +0200 Subject: [PATCH] fust fmt --- sqlx-core/src/any/connection/mod.rs | 3 +-- sqlx-core/src/any/driver.rs | 12 +++++++++--- sqlx-core/src/connection.rs | 20 +++++++++++++------- sqlx-core/src/migrate/migrate.rs | 2 +- sqlx-core/src/testing/mod.rs | 4 +++- sqlx-core/src/transaction.rs | 5 ++--- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/sqlx-core/src/any/connection/mod.rs b/sqlx-core/src/any/connection/mod.rs index 6ccbdaa629..7d19c6f81f 100644 --- a/sqlx-core/src/any/connection/mod.rs +++ b/sqlx-core/src/any/connection/mod.rs @@ -61,8 +61,7 @@ impl AnyConnection { #[cfg(feature = "migrate")] pub(crate) fn get_migrate( &mut self, - ) -> crate::Result<&mut (dyn crate::migrate::Migrate + Send + 'static)> - { + ) -> crate::Result<&mut (dyn crate::migrate::Migrate + Send + 'static)> { self.backend.as_migrate() } } diff --git a/sqlx-core/src/any/driver.rs b/sqlx-core/src/any/driver.rs index b8eb3a81b5..0ad529ea18 100644 --- a/sqlx-core/src/any/driver.rs +++ b/sqlx-core/src/any/driver.rs @@ -67,10 +67,16 @@ impl AnyDriver { { Self { migrate_database: Some(AnyMigrateDatabase { - create_database: DebugFn(|url| Box::pin(async move { DB::create_database(url).await })), - database_exists: DebugFn(|url| Box::pin(async move { DB::database_exists(url).await })), + create_database: DebugFn(|url| { + Box::pin(async move { DB::create_database(url).await }) + }), + database_exists: DebugFn(|url| { + Box::pin(async move { DB::database_exists(url).await }) + }), drop_database: DebugFn(|url| Box::pin(async move { DB::drop_database(url).await })), - force_drop_database: DebugFn(|url| Box::pin(async move { DB::force_drop_database(url).await })), + force_drop_database: DebugFn(|url| { + Box::pin(async move { DB::force_drop_database(url).await }) + }), }), ..Self::without_migrate::() } diff --git a/sqlx-core/src/connection.rs b/sqlx-core/src/connection.rs index 4538a096fd..adf6e04df3 100644 --- a/sqlx-core/src/connection.rs +++ b/sqlx-core/src/connection.rs @@ -1,6 +1,6 @@ use crate::database::{Database, HasStatementCache}; -use std::future::Future; use crate::error::Error; +use std::future::Future; use crate::transaction::Transaction; use futures_core::future::BoxFuture; @@ -46,7 +46,9 @@ pub trait Connection: Send { /// Begin a new transaction or establish a savepoint within the active transaction. /// /// Returns a [`Transaction`] for controlling and tracking the new transaction. - fn begin(&mut self) -> impl Future, Error>> + Send + '_ + fn begin( + &mut self, + ) -> impl Future, Error>> + Send + '_ where Self: Sized; @@ -67,7 +69,10 @@ pub trait Connection: Send { /// })).await /// # } /// ``` - fn transaction<'a, F, R, E>(&'a mut self, callback: F) -> impl Future> + Send + 'a + fn transaction<'a, F, R, E>( + &'a mut self, + callback: F, + ) -> impl Future> + Send + 'a where for<'c> F: FnOnce(&'c mut Transaction<'_, Self::Database>) -> BoxFuture<'c, Result> + 'a @@ -137,7 +142,7 @@ pub trait Connection: Send { /// /// A value of [`Options`][Self::Options] is parsed from the provided connection string. This parsing /// is database-specific. - #[inline] + #[inline] fn connect(url: &str) -> impl Future> + Send + 'static where Self: Sized, @@ -147,11 +152,12 @@ pub trait Connection: Send { async move { Self::connect_with(&options?).await } } - /// Establish a new database connection with the provided options. - fn connect_with(options: &Self::Options) -> impl Future> + Send + '_ + fn connect_with( + options: &Self::Options, + ) -> impl Future> + Send + '_ where - Self: Sized + Self: Sized, { options.connect() } diff --git a/sqlx-core/src/migrate/migrate.rs b/sqlx-core/src/migrate/migrate.rs index 322f0d1671..e7b99906ec 100644 --- a/sqlx-core/src/migrate/migrate.rs +++ b/sqlx-core/src/migrate/migrate.rs @@ -1,8 +1,8 @@ use crate::error::Error; use crate::migrate::{AppliedMigration, MigrateError, Migration}; use futures_core::future::BoxFuture; -use std::time::Duration; use std::future::Future; +use std::time::Duration; pub trait MigrateDatabase { // create database in url diff --git a/sqlx-core/src/testing/mod.rs b/sqlx-core/src/testing/mod.rs index ae963369c9..ad194b5189 100644 --- a/sqlx-core/src/testing/mod.rs +++ b/sqlx-core/src/testing/mod.rs @@ -24,7 +24,9 @@ pub trait TestSupport: Database { /// /// The implementation may require `DATABASE_URL` to be set in order to manage databases. /// The user credentials it contains must have the privilege to create and drop databases. - fn test_context(args: &TestArgs) -> impl Future, Error>> + Send + '_; + fn test_context( + args: &TestArgs, + ) -> impl Future, Error>> + Send + '_; fn cleanup_test(db_name: &str) -> impl Future> + Send + '_; diff --git a/sqlx-core/src/transaction.rs b/sqlx-core/src/transaction.rs index a174ad8b07..3b02ae6ad9 100644 --- a/sqlx-core/src/transaction.rs +++ b/sqlx-core/src/transaction.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use std::future::Future; use std::fmt::{self, Debug, Formatter}; +use std::future::Future; use std::ops::{Deref, DerefMut}; use futures_core::future::BoxFuture; @@ -31,7 +31,6 @@ pub trait TransactionManager { conn: &mut ::Connection, ) -> impl Future> + Send; - /// Starts to abort the active transaction or restore from the most recent snapshot. fn start_rollback(conn: &mut ::Connection); } @@ -233,7 +232,7 @@ impl<'c, 't, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<' type Connection = &'t mut ::Connection; #[inline] -fn acquire(self) -> BoxFuture<'t, Result> { + fn acquire(self) -> BoxFuture<'t, Result> { Box::pin(futures_util::future::ok(&mut **self)) }