Skip to content

Commit

Permalink
Fix: address Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Aug 14, 2022
1 parent a0f028a commit 5f3e7ae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion postgres-openssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ 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).
#[cfg(feature = "runtime")]
#[derive(Clone)]
pub struct MakeTlsConnector {
connector: SslConnector,
config: Arc<dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send>,
config: Arc<ConfigCallback>,
}

#[cfg(feature = "runtime")]
Expand Down
4 changes: 2 additions & 2 deletions postgres-types/src/special.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
/// Represents `infinity`, a date that is later than all other dates.
PosInfinity,
Expand Down Expand Up @@ -55,7 +55,7 @@ impl<T: ToSql> ToSql for Date<T> {

/// 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<T> {
/// Represents `infinity`, a timestamp that is later than all other timestamps.
PosInfinity,
Expand Down
14 changes: 7 additions & 7 deletions tokio-postgres/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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),
Expand Down Expand Up @@ -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<String>,
pub(crate) password: Option<Vec<u8>>,
Expand Down Expand Up @@ -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,
_ => {
Expand Down Expand Up @@ -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)))?;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5f3e7ae

Please sign in to comment.