Skip to content

Commit 9c20d03

Browse files
committed
Bump to 2021 edition, inline formats, lints
* Bump Rust edition 2018 -> 2021 * Use new inline formatting, i.e. `format!("{v}")` instead of `format!("{}", v)` (simple cases only) * use more specific asserts like `assert_ne!` * ignore intellij IDE files * remove a few un-needed namespace prefixes
1 parent 8781965 commit 9c20d03

File tree

9 files changed

+24
-23
lines changed

9 files changed

+24
-23
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/

bb8/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.8.0"
44
description = "Full-featured async (tokio-based) connection pool (like r2d2)"
55
license = "MIT"
66
repository = "https://github.com/djc/bb8"
7-
edition = "2018"
7+
edition = "2021"
88
workspace = ".."
99
readme = "../README.md"
1010

bb8/src/api.rs

+9-7
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`.
@@ -380,7 +382,7 @@ where
380382
{
381383
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
382384
match *self {
383-
RunError::User(ref err) => write!(f, "{}", err),
385+
RunError::User(ref err) => write!(f, "{err}"),
384386
RunError::TimedOut => write!(f, "Timed out in bb8"),
385387
}
386388
}

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/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.8.0"
44
description = "Full-featured async (tokio-based) postgres connection pool (like r2d2)"
55
license = "MIT"
66
repository = "https://github.com/djc/bb8"
7-
edition = "2018"
7+
edition = "2021"
88

99
[features]
1010
"with-bit-vec-0_6" = ["tokio-postgres/with-bit-vec-0_6"]

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ 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

2323
let pool = match Pool::builder().build(pg_mgr).await {
2424
Ok(pool) => pool,
25-
Err(e) => panic!("bb8 error {}", e),
25+
Err(e) => panic!("bb8 error {e}"),
2626
};
2727

2828
let _ = Server::bind(&addr)
@@ -40,7 +40,7 @@ async fn main() {
4040
}
4141
Err(e) => {
4242
println!("Sending error response");
43-
Response::new(Body::from(format!("Internal error {:?}", e)))
43+
Response::new(Body::from(format!("Internal error {e:?}")))
4444
}
4545
})
4646
}
@@ -57,5 +57,5 @@ async fn handler(
5757
let stmt = conn.prepare("SELECT 1").await?;
5858
let row = conn.query_one(&stmt, &[]).await?;
5959
let v = row.get::<usize, i32>(0);
60-
Ok(Response::new(Body::from(format!("Got results {:?}", v))))
60+
Ok(Response::new(Body::from(format!("Got results {v:?}"))))
6161
}

postgres/examples/static_select.rs

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

1818
let pool = match Pool::builder().build(pg_mgr).await {
1919
Ok(pool) => pool,
20-
Err(e) => panic!("builder error: {:?}", e),
20+
Err(e) => panic!("builder error: {e:?}"),
2121
};
2222

2323
let connection = pool.get().await.unwrap();

redis/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.11.0"
44
description = "Full-featured async (tokio-based) redis connection pool (like r2d2)"
55
license = "MIT"
66
repository = "https://github.com/djc/bb8"
7-
edition = "2018"
7+
edition = "2021"
88

99
[dependencies]
1010
async-trait = "0.1"

0 commit comments

Comments
 (0)