Skip to content

Commit a322aba

Browse files
committed
Apply suggestions from clippy 1.88
1 parent aff7441 commit a322aba

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

examples/client.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{env, fs, io};
1515
fn main() {
1616
// Send GET request and inspect result, with proper error handling.
1717
if let Err(e) = run_client() {
18-
eprintln!("FAILED: {}", e);
18+
eprintln!("FAILED: {e}");
1919
std::process::exit(1);
2020
}
2121
}
@@ -34,7 +34,7 @@ async fn run_client() -> io::Result<()> {
3434

3535
// First parameter is target URL (mandatory).
3636
let url = match env::args().nth(1) {
37-
Some(ref url) => Uri::from_str(url).map_err(|e| error(format!("{}", e)))?,
37+
Some(ref url) => Uri::from_str(url).map_err(|e| error(format!("{e}")))?,
3838
None => {
3939
println!("Usage: client <url> <ca_store>");
4040
return Ok(());
@@ -44,8 +44,8 @@ async fn run_client() -> io::Result<()> {
4444
// Second parameter is custom Root-CA store (optional, defaults to native cert store).
4545
let mut ca = match env::args().nth(2) {
4646
Some(ref path) => {
47-
let f = fs::File::open(path)
48-
.map_err(|e| error(format!("failed to open {}: {}", path, e)))?;
47+
let f =
48+
fs::File::open(path).map_err(|e| error(format!("failed to open {path}: {e}")))?;
4949
let rd = io::BufReader::new(f);
5050
Some(rd)
5151
}
@@ -86,15 +86,15 @@ async fn run_client() -> io::Result<()> {
8686
let res = client
8787
.get(url)
8888
.await
89-
.map_err(|e| error(format!("Could not get: {:?}", e)))?;
89+
.map_err(|e| error(format!("Could not get: {e:?}")))?;
9090
println!("Status:\n{}", res.status());
9191
println!("Headers:\n{:#?}", res.headers());
9292

9393
let body = res
9494
.into_body()
9595
.collect()
9696
.await
97-
.map_err(|e| error(format!("Could not get body: {:?}", e)))?
97+
.map_err(|e| error(format!("Could not get body: {e:?}")))?
9898
.to_bytes();
9999
println!("Body:\n{}", String::from_utf8_lossy(&body));
100100

examples/server.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use tokio_rustls::TlsAcceptor;
2323
fn main() {
2424
// Serve an echo service over HTTPS, with proper error handling.
2525
if let Err(e) = run_server() {
26-
eprintln!("FAILED: {}", e);
26+
eprintln!("FAILED: {e}");
2727
std::process::exit(1);
2828
}
2929
}
@@ -52,7 +52,7 @@ async fn run_server() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5252
// Load private key.
5353
let key = load_private_key("examples/sample.rsa")?;
5454

55-
println!("Starting to serve on https://{}", addr);
55+
println!("Starting to serve on https://{addr}");
5656

5757
// Create a TCP listener via tokio.
5858
let incoming = TcpListener::bind(&addr).await?;
@@ -118,8 +118,8 @@ async fn echo(req: Request<Incoming>) -> Result<Response<Full<Bytes>>, hyper::Er
118118
// Load public certificate from file.
119119
fn load_certs(filename: &str) -> io::Result<Vec<CertificateDer<'static>>> {
120120
// Open certificate file.
121-
let certfile = fs::File::open(filename)
122-
.map_err(|e| error(format!("failed to open {}: {}", filename, e)))?;
121+
let certfile =
122+
fs::File::open(filename).map_err(|e| error(format!("failed to open {filename}: {e}")))?;
123123
let mut reader = io::BufReader::new(certfile);
124124

125125
// Load and return certificate.
@@ -129,8 +129,8 @@ fn load_certs(filename: &str) -> io::Result<Vec<CertificateDer<'static>>> {
129129
// Load private key from file.
130130
fn load_private_key(filename: &str) -> io::Result<PrivateKeyDer<'static>> {
131131
// Open keyfile.
132-
let keyfile = fs::File::open(filename)
133-
.map_err(|e| error(format!("failed to open {}: {}", filename, e)))?;
132+
let keyfile =
133+
fs::File::open(filename).map_err(|e| error(format!("failed to open {filename}: {e}")))?;
134134
let mut reader = io::BufReader::new(keyfile);
135135

136136
// Load and return a single private key.

src/config.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,14 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
9393
match roots.add(cert) {
9494
Ok(_) => valid_count += 1,
9595
Err(err) => {
96-
crate::log::debug!("certificate parsing failed: {:?}", err);
96+
crate::log::debug!("certificate parsing failed: {err:?}");
9797
invalid_count += 1
9898
}
9999
}
100100
}
101101

102102
crate::log::debug!(
103-
"with_native_roots processed {} valid and {} invalid certs",
104-
valid_count,
105-
invalid_count
103+
"with_native_roots processed {valid_count} valid and {invalid_count} invalid certs"
106104
);
107105
if roots.is_empty() {
108106
crate::log::debug!("no valid native root CA certificates found");

tests/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn wait_for_server(addr: &str) {
2929
}
3030
thread::sleep(time::Duration::from_millis(i * 100));
3131
}
32-
panic!("failed to connect to {:?} after 10 tries", addr);
32+
panic!("failed to connect to {addr:?} after 10 tries");
3333
}
3434

3535
#[test]
@@ -55,7 +55,7 @@ fn server() {
5555
let output = Command::new("curl")
5656
.arg("--insecure")
5757
.arg("--http1.0")
58-
.arg(format!("https://{}", addr))
58+
.arg(format!("https://{addr}"))
5959
.output()
6060
.expect("cannot run curl");
6161

@@ -87,7 +87,7 @@ fn custom_ca_store() {
8787
wait_for_server(addr);
8888

8989
let rc = client_command()
90-
.arg(format!("https://{}", addr))
90+
.arg(format!("https://{addr}"))
9191
.arg("examples/sample.pem")
9292
.output()
9393
.expect("cannot run client example");

0 commit comments

Comments
 (0)