From 73cbaed57ca1c28345aed697e09c13fe87dc8e9a Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 7 Jun 2022 16:42:28 -0400 Subject: [PATCH] Minor lints * use more specific asserts like `assert_ne!` * ignore intellij IDE files * remove a few un-needed namespace prefixes * link fixes --- .gitignore | 3 ++- README.md | 2 +- bb8/src/api.rs | 14 ++++++++------ bb8/tests/test.rs | 8 ++++---- postgres/examples/custom_state.rs | 4 +--- postgres/examples/hyper.rs | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 7a70347..41ffe4b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /target/ **/*.rs.bk Cargo.lock -*~ \ No newline at end of file +*~ +.idea/ diff --git a/README.md b/README.md index 1b2dd58..94470da 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Crates.io](https://img.shields.io/crates/v/bb8.svg)](https://crates.io/crates/bb8) [![Build status](https://github.com/djc/bb8/workflows/CI/badge.svg)](https://github.com/djc/bb8/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/djc/bb8/branch/main/graph/badge.svg)](https://codecov.io/gh/djc/bb8) -[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE-MIT) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) A full-featured connection pool, designed for asynchronous connections (using tokio). Originally based on [r2d2](https://github.com/sfackler/r2d2). diff --git a/bb8/src/api.rs b/bb8/src/api.rs index 963b9d0..561120b 100644 --- a/bb8/src/api.rs +++ b/bb8/src/api.rs @@ -157,13 +157,14 @@ impl Builder { /// If set, connections will be closed at the next reaping after surviving /// past this duration. /// - /// If a connection reachs its maximum lifetime while checked out it will be + /// If a connection reaches its maximum lifetime while checked out it will be /// closed when it is returned to the pool. /// /// Defaults to 30 minutes. pub fn max_lifetime(mut self, max_lifetime: Option) -> Builder { - assert!( - max_lifetime != Some(Duration::from_secs(0)), + assert_ne!( + max_lifetime, + Some(Duration::from_secs(0)), "max_lifetime must be greater than zero!" ); self.max_lifetime = max_lifetime; @@ -177,8 +178,9 @@ impl Builder { /// /// Defaults to 10 minutes. pub fn idle_timeout(mut self, idle_timeout: Option) -> Builder { - assert!( - idle_timeout != Some(Duration::from_secs(0)), + assert_ne!( + idle_timeout, + Some(Duration::from_secs(0)), "idle_timeout must be greater than zero!" ); self.idle_timeout = idle_timeout; @@ -277,7 +279,7 @@ pub trait ManageConnection: Sized + Send + Sync + 'static { /// A trait which provides functionality to initialize a connection #[async_trait] pub trait CustomizeConnection: - std::fmt::Debug + Send + Sync + 'static + fmt::Debug + Send + Sync + 'static { /// Called with connections immediately after they are returned from /// `ManageConnection::connect`. diff --git a/bb8/tests/test.rs b/bb8/tests/test.rs index a710183..5b31b4d 100644 --- a/bb8/tests/test.rs +++ b/bb8/tests/test.rs @@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::Mutex; use std::task::Poll; use std::time::Duration; -use std::{error, fmt, mem}; +use std::{error, fmt}; use async_trait::async_trait; use futures_channel::oneshot; @@ -270,7 +270,7 @@ async fn test_lazy_initialization_failure() { .build_unchecked(manager); let res = pool.get().await; - assert_eq!(res.unwrap_err(), bb8::RunError::TimedOut); + assert_eq!(res.unwrap_err(), RunError::TimedOut); } #[tokio::test] @@ -547,7 +547,7 @@ async fn test_conns_drop_on_pool_drop() { .await .unwrap(); - mem::drop(pool); + drop(pool); for _ in 0u8..10 { if DROPPED.load(Ordering::SeqCst) == 10 { @@ -741,7 +741,7 @@ async fn test_customize_connection_acquire() { #[derive(Debug, Default)] struct CountingCustomizer { - count: std::sync::atomic::AtomicUsize, + count: AtomicUsize, } #[async_trait] diff --git a/postgres/examples/custom_state.rs b/postgres/examples/custom_state.rs index 43b54c0..0a7bb86 100644 --- a/postgres/examples/custom_state.rs +++ b/postgres/examples/custom_state.rs @@ -15,9 +15,7 @@ use tokio_postgres::{Client, Error, Socket, Statement}; // docker run --name gotham-middleware-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres #[tokio::main] async fn main() { - let config = - tokio_postgres::config::Config::from_str("postgresql://postgres:docker@localhost:5432") - .unwrap(); + let config = Config::from_str("postgresql://postgres:docker@localhost:5432").unwrap(); let pg_mgr = CustomPostgresConnectionManager::new(config, tokio_postgres::NoTls); let pool = Pool::builder() diff --git a/postgres/examples/hyper.rs b/postgres/examples/hyper.rs index e4b330e..788dad8 100644 --- a/postgres/examples/hyper.rs +++ b/postgres/examples/hyper.rs @@ -16,7 +16,7 @@ async fn main() { let pg_mgr = PostgresConnectionManager::new_from_stringlike( "postgresql://postgres:mysecretpassword@localhost:5432", - tokio_postgres::NoTls, + NoTls, ) .unwrap();