Skip to content

Commit f30e1c1

Browse files
committed
make clippy happy
1 parent 49d461c commit f30e1c1

File tree

13 files changed

+24
-24
lines changed

13 files changed

+24
-24
lines changed

examples/demo-client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async fn main() -> Result<()> {
1717
// read http response
1818
let mut buf = vec![0; 1024];
1919
let n = stream.read(&mut buf).await?;
20-
println!("read {} bytes", n);
20+
println!("read {n} bytes");
2121
println!("{}", String::from_utf8_lossy(&buf[..n]));
2222

2323
Ok(())

examples/dns-query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async fn main() -> Result<()> {
7575
assert_eq!(&domain, &opt.domain);
7676

7777
let addr = dns::extract_ipaddr_from_dns_message(&message)?;
78-
println!("{}", addr);
78+
println!("{addr}");
7979

8080
Ok(())
8181
}
@@ -100,7 +100,7 @@ async fn dns_query_from_server(opt: &CmdOpt, msg_buf: &[u8]) -> Result<Vec<u8>>
100100
// read dns response
101101
let mut buf = vec![0; 1500];
102102
let n = tokio::time::timeout(timeout, stream.read(&mut buf)).await??;
103-
log::trace!("read {} bytes", n);
103+
log::trace!("read {n} bytes");
104104
buf.truncate(n);
105105
buf
106106
}

examples/echo-server.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ async fn tcp_main<A: ToSocketAddrs>(addr: A, tcp_timeout: u64) -> std::io::Resul
2525
tokio::spawn(async move {
2626
let block = async move {
2727
let mut buf = vec![0; 1024];
28-
log::info!("[TCP] incoming peer {}", peer);
28+
log::info!("[TCP] incoming peer {peer}");
2929
loop {
3030
let duration = std::time::Duration::from_secs(tcp_timeout);
3131
let n = tokio::time::timeout(duration, socket.read(&mut buf)).await??;
3232
if n == 0 {
33-
log::info!("[TCP] {} exit", peer);
33+
log::info!("[TCP] {peer} exit");
3434
break;
3535
}
3636
let amt = socket.write(&buf[0..n]).await?;
37-
log::info!("[TCP] Echoed {}/{} bytes to {}", amt, n, peer);
37+
log::info!("[TCP] Echoed {amt}/{n} bytes to {peer}");
3838
}
3939
Ok::<(), std::io::Error>(())
4040
};
4141
if let Err(err) = block.await {
42-
log::info!("[TCP] {}", err);
42+
log::info!("[TCP] {err}");
4343
}
4444
});
4545
}
@@ -55,7 +55,7 @@ async fn udp_main<A: ToSocketAddrs>(addr: A) -> std::io::Result<()> {
5555
loop {
5656
if let Some((size, peer)) = to_send {
5757
let amt = socket.send_to(&buf[..size], &peer).await?;
58-
log::info!("[UDP] Echoed {}/{} bytes to {}", amt, size, peer);
58+
log::info!("[UDP] Echoed {amt}/{size} bytes to {peer}");
5959
}
6060

6161
to_send = Some(socket.recv_from(&mut buf).await?);

examples/s5-server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub(crate) async fn handle_s5_upd_associate(associate: UdpAssociate<associate::N
216216
}
217217
},
218218
_ = reply_listener.wait_until_closed() => {
219-
log::trace!("[UDP] {} listener closed", listen_addr);
219+
log::trace!("[UDP] {listen_addr} listener closed");
220220
break Ok::<_, Error>(());
221221
},
222222
};

src/client/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub trait Socks5Reader: AsyncReadExt + Unpin {
6262
let value = self.read_u8().await?;
6363
match Reply::try_from(value)? {
6464
Reply::Succeeded => Ok(()),
65-
reply => Err(format!("{}", reply).into()),
65+
reply => Err(format!("{reply}").into()),
6666
}
6767
}
6868

@@ -555,7 +555,7 @@ mod tests {
555555
Ok::<_, Error>(())
556556
};
557557
if let Err(e) = run_block.await {
558-
println!("{:?}", e);
558+
println!("{e:?}");
559559
}
560560
}
561561

src/protocol/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum AddressType {
2121
impl TryFrom<u8> for AddressType {
2222
type Error = std::io::Error;
2323
fn try_from(code: u8) -> core::result::Result<Self, Self::Error> {
24-
let err = format!("Unsupported address type code {0:#x}", code);
24+
let err = format!("Unsupported address type code {code:#x}");
2525
match code {
2626
0x01 => Ok(AddressType::IPv4),
2727
0x03 => Ok(AddressType::Domain),

src/protocol/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl TryFrom<u8> for Command {
99
type Error = std::io::Error;
1010

1111
fn try_from(code: u8) -> std::result::Result<Self, Self::Error> {
12-
let err = format!("Unsupported command code {0:#x}", code);
12+
let err = format!("Unsupported command code {code:#x}");
1313
match code {
1414
0x01 => Ok(Command::Connect),
1515
0x02 => Ok(Command::Bind),

src/protocol/handshake/auth_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl std::fmt::Display for AuthMethod {
5555
AuthMethod::NoAuth => write!(f, "NoAuth"),
5656
AuthMethod::GssApi => write!(f, "GssApi"),
5757
AuthMethod::UserPass => write!(f, "UserPass"),
58-
AuthMethod::IanaReserved(value) => write!(f, "IanaReserved({0:#x})", value),
59-
AuthMethod::Private(value) => write!(f, "Private({0:#x})", value),
58+
AuthMethod::IanaReserved(value) => write!(f, "IanaReserved({value:#x})"),
59+
AuthMethod::Private(value) => write!(f, "Private({value:#x})"),
6060
AuthMethod::NoAcceptableMethods => write!(f, "NoAcceptableMethods"),
6161
}
6262
}

src/protocol/handshake/password_method/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl std::fmt::Display for UserKey {
2626
(false, false) => {
2727
let username = percent_encode(self.username.as_bytes(), NON_ALPHANUMERIC).to_string();
2828
let password = percent_encode(self.password.as_bytes(), NON_ALPHANUMERIC).to_string();
29-
write!(f, "{}:{}", username, password)
29+
write!(f, "{username}:{password}")
3030
}
3131
}
3232
}

src/protocol/handshake/password_method/request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl StreamOperation for Request {
3333
let ver = ver[0];
3434

3535
if ver != super::SUBNEGOTIATION_VERSION {
36-
let err = format!("Unsupported sub-negotiation version {0:#x}", ver);
36+
let err = format!("Unsupported sub-negotiation version {ver:#x}");
3737
return Err(std::io::Error::new(std::io::ErrorKind::Unsupported, err));
3838
}
3939

@@ -82,7 +82,7 @@ impl AsyncStreamOperation for Request {
8282
let ver = r.read_u8().await?;
8383

8484
if ver != super::SUBNEGOTIATION_VERSION {
85-
let err = format!("Unsupported sub-negotiation version {0:#x}", ver);
85+
let err = format!("Unsupported sub-negotiation version {ver:#x}");
8686
return Err(std::io::Error::new(std::io::ErrorKind::Unsupported, err));
8787
}
8888

0 commit comments

Comments
 (0)