Skip to content

Commit 41c2183

Browse files
committed
Fix clippy
1 parent 75c51d9 commit 41c2183

File tree

6 files changed

+18
-24
lines changed

6 files changed

+18
-24
lines changed

src/conn/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,21 +1450,20 @@ mod test {
14501450

14511451
let _ = conn.query_drop("DROP USER 'test_user'@'%'").await;
14521452

1453-
let query = format!("CREATE USER 'test_user'@'%' IDENTIFIED WITH {}", plug);
1453+
let query = format!("CREATE USER 'test_user'@'%' IDENTIFIED WITH {plug}");
14541454
conn.query_drop(query).await.unwrap();
14551455

14561456
if conn.inner.version < (8, 0, 11) {
1457-
conn.query_drop(format!("SET old_passwords = {}", val))
1457+
conn.query_drop(format!("SET old_passwords = {val}"))
14581458
.await
14591459
.unwrap();
14601460
conn.query_drop(format!(
1461-
"SET PASSWORD FOR 'test_user'@'%' = PASSWORD('{}')",
1462-
pass
1461+
"SET PASSWORD FOR 'test_user'@'%' = PASSWORD('{pass}')"
14631462
))
14641463
.await
14651464
.unwrap();
14661465
} else {
1467-
conn.query_drop(format!("SET PASSWORD FOR 'test_user'@'%' = '{}'", pass))
1466+
conn.query_drop(format!("SET PASSWORD FOR 'test_user'@'%' = '{pass}'"))
14681467
.await
14691468
.unwrap();
14701469
};
@@ -1481,11 +1480,11 @@ mod test {
14811480
}
14821481

14831482
if crate::test_misc::test_compression() {
1484-
assert!(format!("{:?}", conn).contains("Compression"));
1483+
assert!(format!("{conn:?}").contains("Compression"));
14851484
}
14861485

14871486
if crate::test_misc::test_ssl() {
1488-
assert!(format!("{:?}", conn).contains("Tls"));
1487+
assert!(format!("{conn:?}").contains("Tls"));
14891488
}
14901489

14911490
conn.disconnect().await?;
@@ -1781,9 +1780,8 @@ mod test {
17811780
let mut conn = Conn::new(get_opts()).await?;
17821781
for x in (MAX_PAYLOAD_LEN - 2)..=(MAX_PAYLOAD_LEN + 2) {
17831782
let long_string = "A".repeat(x);
1784-
let result: Vec<(String, u8)> = conn
1785-
.query(format!(r"SELECT '{}', 231", long_string))
1786-
.await?;
1783+
let result: Vec<(String, u8)> =
1784+
conn.query(format!(r"SELECT '{long_string}', 231")).await?;
17871785
assert_eq!((long_string, 231_u8), result[0]);
17881786
}
17891787
conn.disconnect().await?;
@@ -2318,7 +2316,7 @@ mod test {
23182316
.tcp_port(listen_addr.port());
23192317
let server_err = match Conn::new(opts).await {
23202318
Err(Error::Server(server_err)) => server_err,
2321-
other => panic!("expected server error but got: {:?}", other),
2319+
other => panic!("expected server error but got: {other:?}"),
23222320
};
23232321
assert_eq!(
23242322
server_err,

src/conn/pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ mod test {
627627

628628
// now we'll kill connections..
629629
for id in ids {
630-
master.query_drop(format!("KILL {}", id)).await?;
630+
master.query_drop(format!("KILL {id}")).await?;
631631
}
632632

633633
// now check, that they're still in the pool..

src/error/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,10 @@ impl From<PacketCodecError> for IoError {
315315
fn from(err: PacketCodecError) -> Self {
316316
match err {
317317
PacketCodecError::Io(err) => err.into(),
318-
PacketCodecError::PacketTooLarge => {
319-
io::Error::new(io::ErrorKind::Other, "packet too large").into()
320-
}
321-
PacketCodecError::PacketsOutOfSync => {
322-
io::Error::new(io::ErrorKind::Other, "packet out of order").into()
323-
}
318+
PacketCodecError::PacketTooLarge => io::Error::other("packet too large").into(),
319+
PacketCodecError::PacketsOutOfSync => io::Error::other("packet out of order").into(),
324320
PacketCodecError::BadCompressedPacketHeader => {
325-
io::Error::new(io::ErrorKind::Other, "bad compressed packet header").into()
321+
io::Error::other("bad compressed packet header").into()
326322
}
327323
}
328324
}

src/io/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{
2626
future::Future,
2727
io::{
2828
self,
29-
ErrorKind::{BrokenPipe, NotConnected, Other},
29+
ErrorKind::{BrokenPipe, NotConnected},
3030
},
3131
mem::replace,
3232
net::SocketAddr,
@@ -141,7 +141,7 @@ impl Future for CheckTcpStream<'_> {
141141
let mut buf = [0_u8; 1];
142142
match self.0.try_read(&mut buf) {
143143
Ok(0) => Poll::Ready(Err(io::Error::new(BrokenPipe, "broken pipe"))),
144-
Ok(_) => Poll::Ready(Err(io::Error::new(Other, "stream should be empty"))),
144+
Ok(_) => Poll::Ready(Err(io::Error::other("stream should be empty"))),
145145
Err(err) if err.kind() == io::ErrorKind::WouldBlock => Poll::Ready(Ok(())),
146146
Err(err) => Poll::Ready(Err(err)),
147147
}

src/queryable/query_result/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ where
100100
self.conn
101101
.get_pending_result()
102102
.map(|pending_result| match pending_result {
103-
Some(PendingResult::Pending(meta)) => meta.columns().len() > 0,
104-
Some(PendingResult::Taken(meta)) => meta.columns().len() > 0,
103+
Some(PendingResult::Pending(meta)) => !meta.columns().is_empty(),
104+
Some(PendingResult::Taken(meta)) => !meta.columns().is_empty(),
105105
None => false,
106106
})
107107
.unwrap_or(false)

src/queryable/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a> Transaction<'a> {
154154
}
155155

156156
if let Some(isolation_level) = isolation_level {
157-
let query = format!("SET TRANSACTION ISOLATION LEVEL {}", isolation_level);
157+
let query = format!("SET TRANSACTION ISOLATION LEVEL {isolation_level}");
158158
conn.as_mut().query_drop(query).await?;
159159
}
160160

0 commit comments

Comments
 (0)