Skip to content

Commit 1f34776

Browse files
committed
Clippy
1 parent 51b23a6 commit 1f34776

File tree

9 files changed

+47
-58
lines changed

9 files changed

+47
-58
lines changed

async-ssh2-lite/demos/smol/src/proxy_jump.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
4545
}))
4646
});
4747

48-
println!("ret_vec: {:?}", ret_vec);
48+
println!("ret_vec:{ret_vec:?}");
4949

5050
Ok(())
5151
}
@@ -99,9 +99,9 @@ async fn run(ex: Arc<Executor<'_>>) -> Result<(), Box<dyn error::Error>> {
9999
channel.exec("hostname").await?;
100100
let mut s = String::new();
101101
channel.read_to_string(&mut s).await?;
102-
println!("bastion hostname: {}", s);
102+
println!("bastion hostname:{s}");
103103
channel.close().await?;
104-
println!("bastion channel exit_status: {}", channel.exit_status()?);
104+
println!("bastion channel exit_status:{}", channel.exit_status()?);
105105

106106
let mut bastion_channel = bastion_session
107107
.channel_direct_tcpip(addr.ip().to_string().as_ref(), addr.port(), None)
@@ -142,14 +142,14 @@ async fn run(ex: Arc<Executor<'_>>) -> Result<(), Box<dyn error::Error>> {
142142
break
143143
},
144144
Ok(n) => {
145-
println!("forward_stream_r read {}", n);
145+
println!("forward_stream_r read {n}");
146146
bastion_channel.write(&buf_forward_stream_r[..n]).await.map(|_| ()).map_err(|err| {
147-
eprintln!("bastion_channel write failed, err {:?}", err);
147+
eprintln!("bastion_channel write failed, err:{err:?}");
148148
err
149149
})?
150150
},
151151
Err(err) => {
152-
eprintln!("forward_stream_r read failed, err {:?}", err);
152+
eprintln!("forward_stream_r read failed, err:{err:?}");
153153

154154
return Err(err);
155155
}
@@ -160,14 +160,14 @@ async fn run(ex: Arc<Executor<'_>>) -> Result<(), Box<dyn error::Error>> {
160160
break
161161
},
162162
Ok(n) => {
163-
println!("bastion_channel read {}", n);
163+
println!("bastion_channel read {n}");
164164
forward_stream_r.write(&buf_bastion_channel[..n]).await.map(|_| ()).map_err(|err| {
165-
eprintln!("forward_stream_r write failed, err {:?}", err);
165+
eprintln!("forward_stream_r write failed, err:{err:?}");
166166
err
167167
})?
168168
},
169169
Err(err) => {
170-
eprintln!("bastion_channel read failed, err {:?}", err);
170+
eprintln!("bastion_channel read failed, err:{err:?}");
171171

172172
return Err(err);
173173
}
@@ -201,9 +201,9 @@ async fn run(ex: Arc<Executor<'_>>) -> Result<(), Box<dyn error::Error>> {
201201
channel.exec("hostname").await?;
202202
let mut s = String::new();
203203
channel.read_to_string(&mut s).await?;
204-
println!("hostname: {}", s);
204+
println!("hostname:{s}");
205205
channel.close().await?;
206-
println!("channel exit_status: {}", channel.exit_status()?);
206+
println!("channel exit_status:{}", channel.exit_status()?);
207207

208208
session.disconnect(None, "foo", None).await?;
209209

@@ -214,14 +214,14 @@ async fn run(ex: Arc<Executor<'_>>) -> Result<(), Box<dyn error::Error>> {
214214

215215
//
216216
task_with_main.await.map_err(|err| {
217-
eprintln!("task_with_main run failed, err {:?}", err);
217+
eprintln!("task_with_main run failed, err:{err:?}");
218218

219219
err
220220
})?;
221221

222222
for receiver in receivers {
223223
let msg = receiver.recv().await.unwrap();
224-
println!("{}", msg);
224+
println!("{msg}");
225225
}
226226

227227
Ok(())

async-ssh2-lite/src/error.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::fmt;
21
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
32

43
use ssh2::Error as Ssh2Error;
@@ -11,9 +10,9 @@ pub enum Error {
1110
Other(Box<dyn std::error::Error + Send + Sync + 'static>),
1211
}
1312

14-
impl fmt::Display for Error {
15-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16-
write!(f, "{:?}", self)
13+
impl core::fmt::Display for Error {
14+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
15+
write!(f, "{self:?}")
1716
}
1817
}
1918
impl std::error::Error for Error {}

async-ssh2-lite/src/session.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,12 @@ where
535535
match join_handle.await {
536536
Ok(_) => {}
537537
Err(err) => {
538-
eprintln!("join_handle failed, err:{:?}", err);
538+
eprintln!("join_handle failed, err:{err:?}");
539539
}
540540
}
541541
}
542542
Err(err) => {
543-
eprintln!("listener.accept failed, err:{:?}", err);
543+
eprintln!("listener.accept failed, err:{err:?}");
544544
}
545545
}
546546
}
@@ -604,12 +604,12 @@ where
604604
match join_handle.await {
605605
Ok(_) => {}
606606
Err(err) => {
607-
eprintln!("join_handle failed, err:{:?}", err);
607+
eprintln!("join_handle failed, err:{err:?}");
608608
}
609609
}
610610
}
611611
Err(err) => {
612-
eprintln!("listener.accept failed, err:{:?}", err);
612+
eprintln!("listener.accept failed, err:{err:?}");
613613
}
614614
}
615615
}

async-ssh2-lite/tests/integration_tests/channel__exec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ async fn __run__session__channel_session__exec<S: AsyncSessionStream + Send + Sy
4545
channel.exec("hostname").await?;
4646
let mut s = String::new();
4747
channel.read_to_string(&mut s).await?;
48-
println!("exec hostname output:{}", s);
48+
println!("exec hostname output:{s}");
4949
channel.close().await?;
5050
println!("exec hostname exit_status:{}", channel.exit_status()?);
5151

5252
let mut channel = session.channel_session().await?;
5353
channel.exec("date").await?;
5454
let mut s = String::new();
5555
channel.read_to_string(&mut s).await?;
56-
println!("exec date output:{}", s);
56+
println!("exec date output:{s}");
5757
channel.close().await?;
5858
println!("exec date exit_status:{}", channel.exit_status()?);
5959

async-ssh2-lite/tests/integration_tests/remote_port_forwarding.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn simple_with_tokio() -> Result<(), Box<dyn error::Error>> {
6161
match server.await {
6262
Ok(_) => {}
6363
Err(err) => {
64-
eprintln!("server error, err:{}", err);
64+
eprintln!("server error, err:{err}");
6565
}
6666
}
6767

@@ -86,7 +86,7 @@ async fn simple_with_tokio() -> Result<(), Box<dyn error::Error>> {
8686
{
8787
Ok(_) => {}
8888
Err(err) => {
89-
eprintln!("session.remote_port_forwarding error, err:{}", err);
89+
eprintln!("session.remote_port_forwarding error, err:{err}");
9090
}
9191
}
9292

@@ -124,25 +124,24 @@ async fn simple_with_tokio() -> Result<(), Box<dyn error::Error>> {
124124
channel
125125
.exec(
126126
format!(
127-
r#"curl http://127.0.0.1:{}/200 -H "x-foo: bar" -v -w "%{{http_code}}""#,
128-
remote_port
127+
r#"curl http://127.0.0.1:{remote_port}/200 -H "x-foo: bar" -v -w "%{{http_code}}""#,
129128
)
130129
.as_ref(),
131130
)
132131
.await?;
133132
let mut s = String::new();
134133
channel.read_to_string(&mut s).await?;
135-
println!("remote_port_forwarding exec curl output:{} i:{}", s, i);
134+
println!("remote_port_forwarding exec curl output:{s} i:{i}");
136135
assert_eq!(s, "200");
137136
channel.close().await?;
138-
println!("remote_port_forwarding exec curl exit_status:{} i:{}", channel.exit_status()?, i);
137+
println!("remote_port_forwarding exec curl exit_status:{} i:{i}", channel.exit_status()?);
139138
Result::<_, Box<dyn error::Error>>::Ok(())
140139
}
141140
})
142141
.collect::<Vec<_>>();
143142

144143
let rets = join_all(futures).await;
145-
println!("remote_port_forwarding exec curl rets:{:?}", rets);
144+
println!("remote_port_forwarding exec curl rets:{rets:?}");
146145
assert!(rets.iter().all(|x| x.is_ok()));
147146

148147
//

async-ssh2-lite/tests/integration_tests/session__channel_forward_listen.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,8 @@ async fn __run__session__channel_forward_listen__with_tokio_spawn<
7676
};
7777
};
7878

79-
println!("run `netstat -tunlp | grep {}` in ssh server", remote_port);
80-
println!(
81-
"run `curl http://127.0.0.1:{}/ -v` in ssh server",
82-
remote_port
83-
);
79+
println!("run `netstat -tunlp | grep {remote_port}` in ssh server");
80+
println!("run `curl http://127.0.0.1:{remote_port}/ -v` in ssh server");
8481

8582
//
8683
let server_task: tokio::task::JoinHandle<Result<(), Box<dyn error::Error + Send + Sync>>> =
@@ -130,7 +127,7 @@ async fn __run__session__channel_forward_listen__with_tokio_spawn<
130127
});
131128
}
132129
Err(err) => {
133-
eprintln!("listener.accept failed, err:{:?}", err);
130+
eprintln!("listener.accept failed, err:{err:?}");
134131
}
135132
}
136133
}
@@ -146,30 +143,26 @@ async fn __run__session__channel_forward_listen__with_tokio_spawn<
146143
let mut channel = session.channel_session().await?;
147144
channel
148145
.exec(
149-
format!(
150-
r#"curl http://127.0.0.1:{}/ -v -w "%{{http_code}}""#,
151-
remote_port
152-
)
153-
.as_ref(),
146+
format!(r#"curl http://127.0.0.1:{remote_port}/ -v -w "%{{http_code}}""#,)
147+
.as_ref(),
154148
)
155149
.await?;
156150
let mut s = String::new();
157151
channel.read_to_string(&mut s).await?;
158-
println!("channel_forward_listen exec curl output:{} i:{}", s, i);
152+
println!("channel_forward_listen exec curl output:{s} i:{i}");
159153
assert_eq!(s, "200");
160154
channel.close().await?;
161155
println!(
162-
"channel_forward_listen exec curl exit_status:{} i:{}",
163-
channel.exit_status()?,
164-
i
156+
"channel_forward_listen exec curl exit_status:{} i:{i}",
157+
channel.exit_status()?
165158
);
166159
Result::<_, Box<dyn error::Error>>::Ok(())
167160
}
168161
})
169162
.collect::<Vec<_>>();
170163

171164
let rets = join_all(futures).await;
172-
println!("channel_forward_listen exec curl rets:{:?}", rets);
165+
println!("channel_forward_listen exec curl rets:{rets:?}");
173166
assert!(rets.iter().all(|x| x.is_ok()));
174167

175168
//

async-ssh2-lite/tests/integration_tests/session__userauth_agent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn __run__session__userauth_agent_with_try_next<
6262
assert!(session.authenticated());
6363
}
6464
Err(err) => {
65-
eprintln!("session.userauth_agent_with_try_next failed, err:{}", err);
65+
eprintln!("session.userauth_agent_with_try_next failed, err:{err}");
6666
assert!(!session.authenticated());
6767
}
6868
}
@@ -82,7 +82,7 @@ async fn __run__session__userauth_agent<S: AsyncSessionStream + Send + Sync + 's
8282
assert!(session.authenticated());
8383
}
8484
Err(err) => {
85-
eprintln!("session.userauth_agent failed, err:{}", err);
85+
eprintln!("session.userauth_agent failed, err:{err}");
8686
assert!(!session.authenticated());
8787
}
8888
}
@@ -92,7 +92,7 @@ async fn __run__session__userauth_agent<S: AsyncSessionStream + Send + Sync + 's
9292
assert!(session.authenticated());
9393
}
9494
Err(err) => {
95-
eprintln!("session.userauth_agent failed, err:{}", err);
95+
eprintln!("session.userauth_agent failed, err:{err}");
9696
assert!(!session.authenticated());
9797
}
9898
}

async-ssh2-lite/tests/integration_tests/session__userauth_password.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async fn simple_with_tokio() -> Result<(), Box<dyn error::Error>> {
3737
.collect::<Vec<_>>();
3838

3939
let rets = join_all(futures).await;
40-
println!("__run__session__userauth_password rets:{:?}", rets);
40+
println!("__run__session__userauth_password rets:{rets:?}");
4141
assert!(rets.iter().all(|x| x.is_ok()));
4242

4343
Ok(())
@@ -69,7 +69,7 @@ fn simple_with_async_io() -> Result<(), Box<dyn error::Error>> {
6969
.collect::<Vec<_>>();
7070

7171
let rets = join_all(futures).await;
72-
println!("__run__session__userauth_password rets:{:?}", rets);
72+
println!("__run__session__userauth_password rets:{rets:?}");
7373
assert!(rets.iter().all(|x| x.is_ok()));
7474

7575
Ok(())
@@ -82,8 +82,7 @@ async fn __run__session__userauth_password<S: AsyncSessionStream + Send + Sync +
8282
) -> Result<(), Box<dyn error::Error>> {
8383
session.handshake().await?;
8484
println!(
85-
"handshake successful, i:{} thread_id:{:?}",
86-
i,
85+
"handshake successful, i:{i} thread_id:{:?}",
8786
thread::current().id()
8887
);
8988

@@ -115,8 +114,7 @@ async fn __run__session__userauth_password<S: AsyncSessionStream + Send + Sync +
115114
}
116115
}
117116
println!(
118-
"session.userauth_password successful, i:{} thread_id:{:?}",
119-
i,
117+
"session.userauth_password successful, i:{i} thread_id:{:?}",
120118
thread::current().id()
121119
);
122120

async-ssh2-lite/tests/integration_tests/sftp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ async fn __run__session__sftp<S: AsyncSessionStream + Send + Sync + 'static>(
4545
sftp.create(&remote_path).await?;
4646

4747
let file_stat = sftp.stat(&remote_path).await?;
48-
println!("sftp file_stat:{:?}", file_stat);
48+
println!("sftp file_stat:{file_stat:?}");
4949

5050
let mut sftp_file = sftp.open(&remote_path).await?;
5151
let file_stat_for_file = sftp_file.stat().await?;
52-
println!("sftp file_stat_for_file:{:?}", file_stat_for_file);
52+
println!("sftp file_stat_for_file:{file_stat_for_file:?}");
5353
sftp_file.close().await?;
5454
assert_eq!(file_stat, file_stat_for_file);
5555

5656
sftp.unlink(&remote_path).await?;
5757

5858
let list = sftp.readdir(&PathBuf::from("/")).await?;
5959
for (file_path, file_stat) in list.iter().take(10) {
60-
println!("sftp file_path:{:?} file_stat:{:?}", file_path, file_stat);
60+
println!("sftp file_path:{file_path:?} file_stat:{file_stat:?}");
6161
}
6262

6363
Ok(())

0 commit comments

Comments
 (0)