Skip to content

Commit 73cbaed

Browse files
nyurikdjc
authored andcommitted
Minor lints
* use more specific asserts like `assert_ne!` * ignore intellij IDE files * remove a few un-needed namespace prefixes * link fixes
1 parent 8781965 commit 73cbaed

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/target/
33
**/*.rs.bk
44
Cargo.lock
5-
*~
5+
*~
6+
.idea/

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Crates.io](https://img.shields.io/crates/v/bb8.svg)](https://crates.io/crates/bb8)
55
[![Build status](https://github.com/djc/bb8/workflows/CI/badge.svg)](https://github.com/djc/bb8/actions?query=workflow%3ACI)
66
[![codecov](https://codecov.io/gh/djc/bb8/branch/main/graph/badge.svg)](https://codecov.io/gh/djc/bb8)
7-
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE-MIT)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
88

99
A full-featured connection pool, designed for asynchronous connections (using
1010
tokio). Originally based on [r2d2](https://github.com/sfackler/r2d2).

bb8/src/api.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ impl<M: ManageConnection> Builder<M> {
157157
/// If set, connections will be closed at the next reaping after surviving
158158
/// past this duration.
159159
///
160-
/// If a connection reachs its maximum lifetime while checked out it will be
160+
/// If a connection reaches its maximum lifetime while checked out it will be
161161
/// closed when it is returned to the pool.
162162
///
163163
/// Defaults to 30 minutes.
164164
pub fn max_lifetime(mut self, max_lifetime: Option<Duration>) -> Builder<M> {
165-
assert!(
166-
max_lifetime != Some(Duration::from_secs(0)),
165+
assert_ne!(
166+
max_lifetime,
167+
Some(Duration::from_secs(0)),
167168
"max_lifetime must be greater than zero!"
168169
);
169170
self.max_lifetime = max_lifetime;
@@ -177,8 +178,9 @@ impl<M: ManageConnection> Builder<M> {
177178
///
178179
/// Defaults to 10 minutes.
179180
pub fn idle_timeout(mut self, idle_timeout: Option<Duration>) -> Builder<M> {
180-
assert!(
181-
idle_timeout != Some(Duration::from_secs(0)),
181+
assert_ne!(
182+
idle_timeout,
183+
Some(Duration::from_secs(0)),
182184
"idle_timeout must be greater than zero!"
183185
);
184186
self.idle_timeout = idle_timeout;
@@ -277,7 +279,7 @@ pub trait ManageConnection: Sized + Send + Sync + 'static {
277279
/// A trait which provides functionality to initialize a connection
278280
#[async_trait]
279281
pub trait CustomizeConnection<C: Send + 'static, E: 'static>:
280-
std::fmt::Debug + Send + Sync + 'static
282+
fmt::Debug + Send + Sync + 'static
281283
{
282284
/// Called with connections immediately after they are returned from
283285
/// `ManageConnection::connect`.

bb8/tests/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
88
use std::sync::Mutex;
99
use std::task::Poll;
1010
use std::time::Duration;
11-
use std::{error, fmt, mem};
11+
use std::{error, fmt};
1212

1313
use async_trait::async_trait;
1414
use futures_channel::oneshot;
@@ -270,7 +270,7 @@ async fn test_lazy_initialization_failure() {
270270
.build_unchecked(manager);
271271

272272
let res = pool.get().await;
273-
assert_eq!(res.unwrap_err(), bb8::RunError::TimedOut);
273+
assert_eq!(res.unwrap_err(), RunError::TimedOut);
274274
}
275275

276276
#[tokio::test]
@@ -547,7 +547,7 @@ async fn test_conns_drop_on_pool_drop() {
547547
.await
548548
.unwrap();
549549

550-
mem::drop(pool);
550+
drop(pool);
551551

552552
for _ in 0u8..10 {
553553
if DROPPED.load(Ordering::SeqCst) == 10 {
@@ -741,7 +741,7 @@ async fn test_customize_connection_acquire() {
741741

742742
#[derive(Debug, Default)]
743743
struct CountingCustomizer {
744-
count: std::sync::atomic::AtomicUsize,
744+
count: AtomicUsize,
745745
}
746746

747747
#[async_trait]

postgres/examples/custom_state.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ use tokio_postgres::{Client, Error, Socket, Statement};
1515
// docker run --name gotham-middleware-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
1616
#[tokio::main]
1717
async fn main() {
18-
let config =
19-
tokio_postgres::config::Config::from_str("postgresql://postgres:docker@localhost:5432")
20-
.unwrap();
18+
let config = Config::from_str("postgresql://postgres:docker@localhost:5432").unwrap();
2119
let pg_mgr = CustomPostgresConnectionManager::new(config, tokio_postgres::NoTls);
2220

2321
let pool = Pool::builder()

postgres/examples/hyper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async fn main() {
1616

1717
let pg_mgr = PostgresConnectionManager::new_from_stringlike(
1818
"postgresql://postgres:mysecretpassword@localhost:5432",
19-
tokio_postgres::NoTls,
19+
NoTls,
2020
)
2121
.unwrap();
2222

0 commit comments

Comments
 (0)