diff --git a/postgres-openssl/src/lib.rs b/postgres-openssl/src/lib.rs index 49fc2807..9fc50b89 100644 --- a/postgres-openssl/src/lib.rs +++ b/postgres-openssl/src/lib.rs @@ -73,6 +73,8 @@ use tokio_postgres::tls::{ChannelBinding, TlsConnect}; #[cfg(test)] mod test; +type ConfigCallback = dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send; + /// A `MakeTlsConnect` implementation using the `openssl` crate. /// /// Requires the `runtime` Cargo feature (enabled by default). @@ -80,7 +82,7 @@ mod test; #[derive(Clone)] pub struct MakeTlsConnector { connector: SslConnector, - config: Arc Result<(), ErrorStack> + Sync + Send>, + config: Arc, } #[cfg(feature = "runtime")] diff --git a/postgres-types/src/special.rs b/postgres-types/src/special.rs index 8579885e..1a865287 100644 --- a/postgres-types/src/special.rs +++ b/postgres-types/src/special.rs @@ -6,7 +6,7 @@ use std::{i32, i64}; use crate::{FromSql, IsNull, ToSql, Type}; /// A wrapper that can be used to represent infinity with `Type::Date` types. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Date { /// Represents `infinity`, a date that is later than all other dates. PosInfinity, @@ -55,7 +55,7 @@ impl ToSql for Date { /// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::Timestamptz` /// types. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Timestamp { /// Represents `infinity`, a timestamp that is later than all other timestamps. PosInfinity, diff --git a/tokio-postgres/src/config.rs b/tokio-postgres/src/config.rs index c026cca4..2c29d629 100644 --- a/tokio-postgres/src/config.rs +++ b/tokio-postgres/src/config.rs @@ -23,7 +23,7 @@ use std::{error, fmt, iter, mem}; use tokio::io::{AsyncRead, AsyncWrite}; /// Properties required of a session. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum TargetSessionAttrs { /// No special properties are required. @@ -33,7 +33,7 @@ pub enum TargetSessionAttrs { } /// TLS configuration. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum SslMode { /// Do not use TLS. @@ -45,7 +45,7 @@ pub enum SslMode { } /// Channel binding configuration. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum ChannelBinding { /// Do not use channel binding. @@ -57,7 +57,7 @@ pub enum ChannelBinding { } /// A host specification. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Host { /// A TCP hostname. Tcp(String), @@ -144,7 +144,7 @@ pub enum Host { /// ```not_rust /// postgresql:///mydb?user=user&host=/var/lib/postgresql /// ``` -#[derive(PartialEq, Clone)] +#[derive(Clone, PartialEq, Eq)] pub struct Config { pub(crate) user: Option, pub(crate) password: Option>, @@ -452,7 +452,7 @@ impl Config { } } "target_session_attrs" => { - let target_session_attrs = match &*value { + let target_session_attrs = match value { "any" => TargetSessionAttrs::Any, "read-write" => TargetSessionAttrs::ReadWrite, _ => { @@ -900,7 +900,7 @@ impl<'a> UrlParser<'a> { #[cfg(unix)] fn host_param(&mut self, s: &str) -> Result<(), Error> { let decoded = Cow::from(percent_encoding::percent_decode(s.as_bytes())); - if decoded.get(0) == Some(&b'/') { + if decoded.first() == Some(&b'/') { self.config.host_path(OsStr::from_bytes(&decoded)); } else { let decoded = str::from_utf8(&decoded).map_err(|e| Error::config_parse(Box::new(e)))?; diff --git a/tokio-postgres/src/connect.rs b/tokio-postgres/src/connect.rs index 4336f90b..88faafe6 100644 --- a/tokio-postgres/src/connect.rs +++ b/tokio-postgres/src/connect.rs @@ -28,7 +28,7 @@ where let port = config .port .get(i) - .or_else(|| config.port.get(0)) + .or_else(|| config.port.first()) .copied() .unwrap_or(5432);