Fix: address Clippy warnings

This commit is contained in:
Basti Ortiz 2022-08-15 00:12:18 +08:00
parent a0f028a008
commit 5f3e7aecad
No known key found for this signature in database
GPG Key ID: 1402D5CB17F48E1B
4 changed files with 13 additions and 11 deletions

View File

@ -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<dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send>,
config: Arc<ConfigCallback>,
}
#[cfg(feature = "runtime")]

View File

@ -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,
@ -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,

View File

@ -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<String>,
pub(crate) password: Option<Vec<u8>>,
@ -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)))?;

View File

@ -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);