From fedd883d91a47f754ade4236a3c2b86d0fb47d7a Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 11 Jun 2020 03:47:19 -0700 Subject: [PATCH] style: rustfmt --- sqlx-core/src/encode.rs | 1 + sqlx-core/src/postgres/connection/describe.rs | 4 ++- .../src/postgres/types/ranges/pg_range.rs | 25 +++++++--------- sqlx-macros/src/derives/encode.rs | 30 +++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/sqlx-core/src/encode.rs b/sqlx-core/src/encode.rs index f1a905eb..7a8f2e2c 100644 --- a/sqlx-core/src/encode.rs +++ b/sqlx-core/src/encode.rs @@ -67,6 +67,7 @@ where } } +#[allow(unused_macros)] macro_rules! impl_encode_for_option { ($DB:ident) => { impl<'q, T> crate::encode::Encode<'q, $DB> for Option diff --git a/sqlx-core/src/postgres/connection/describe.rs b/sqlx-core/src/postgres/connection/describe.rs index 811be8c5..8d65101b 100644 --- a/sqlx-core/src/postgres/connection/describe.rs +++ b/sqlx-core/src/postgres/connection/describe.rs @@ -221,7 +221,9 @@ WHERE rngtypid = $1 .fetch_one(self) .await?; - let pg_type = PgType::try_from_oid(oid).ok_or_else(|| err_protocol!("Trying to retrieve a DB type that doesn't exist in SQLx"))?; + let pg_type = PgType::try_from_oid(oid).ok_or_else(|| { + err_protocol!("Trying to retrieve a DB type that doesn't exist in SQLx") + })?; Ok(PgTypeInfo(PgType::Custom(Arc::new(PgCustomType { kind: PgTypeKind::Range(PgTypeInfo(pg_type)), diff --git a/sqlx-core/src/postgres/types/ranges/pg_range.rs b/sqlx-core/src/postgres/types/ranges/pg_range.rs index efaa93d9..fb5402e8 100644 --- a/sqlx-core/src/postgres/types/ranges/pg_range.rs +++ b/sqlx-core/src/postgres/types/ranges/pg_range.rs @@ -11,17 +11,17 @@ use core::{ }; bitflags::bitflags! { - struct RangeFlags: u8 { - const EMPTY = 0x01; - const LB_INC = 0x02; - const UB_INC = 0x04; - const LB_INF = 0x08; - const UB_INF = 0x10; - const LB_NULL = 0x20; - const UB_NULL = 0x40; - const CONTAIN_EMPTY = 0x80; - } + struct RangeFlags: u8 { + const EMPTY = 0x01; + const LB_INC = 0x02; + const UB_INC = 0x04; + const LB_INF = 0x08; + const UB_INF = 0x10; + const LB_NULL = 0x20; + const UB_NULL = 0x40; + const CONTAIN_EMPTY = 0x80; } +} #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct PgRange { @@ -31,10 +31,7 @@ pub struct PgRange { impl PgRange { pub fn new(start: Bound, end: Bound) -> Self { - Self { - start, - end - } + Self { start, end } } } diff --git a/sqlx-macros/src/derives/encode.rs b/sqlx-macros/src/derives/encode.rs index 854d17e9..af6a07d6 100644 --- a/sqlx-macros/src/derives/encode.rs +++ b/sqlx-macros/src/derives/encode.rs @@ -103,24 +103,24 @@ fn expand_derive_encode_weak_enum( let ident = &input.ident; Ok(quote!( - impl<'q, DB: sqlx::Database> sqlx::encode::Encode<'q, DB> for #ident where #repr: sqlx::encode::Encode<'q, DB> { - fn encode(self, buf: &mut >::ArgumentBuffer) -> sqlx::encode::IsNull { - sqlx::encode::Encode::encode((self as #repr), buf) + impl<'q, DB: sqlx::Database> sqlx::encode::Encode<'q, DB> for #ident where #repr: sqlx::encode::Encode<'q, DB> { + fn encode(self, buf: &mut >::ArgumentBuffer) -> sqlx::encode::IsNull { + sqlx::encode::Encode::encode((self as #repr), buf) + } + + fn encode_by_ref(&self, buf: &mut >::ArgumentBuffer) -> sqlx::encode::IsNull { + sqlx::encode::Encode::encode_by_ref(&(*self as #repr), buf) + } + + fn produces(&self) -> Option { + >::type_info().into() } - fn encode_by_ref(&self, buf: &mut >::ArgumentBuffer) -> sqlx::encode::IsNull { - sqlx::encode::Encode::encode_by_ref(&(*self as #repr), buf) + fn size_hint(&self) -> usize { + sqlx::encode::Encode::size_hint(&(*self as #repr)) } - - fn produces(&self) -> Option { - >::type_info().into() - } - - fn size_hint(&self) -> usize { - sqlx::encode::Encode::size_hint(&(*self as #repr)) - } - } - )) + } + )) } fn expand_derive_encode_strong_enum(