diff --git a/examples/client.rs b/examples/client.rs index c45bc2a..71c6888 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -15,7 +15,7 @@ use std::{env, fs, io}; fn main() { // Send GET request and inspect result, with proper error handling. if let Err(e) = run_client() { - eprintln!("FAILED: {}", e); + eprintln!("FAILED: {e}"); std::process::exit(1); } } @@ -34,7 +34,7 @@ async fn run_client() -> io::Result<()> { // First parameter is target URL (mandatory). let url = match env::args().nth(1) { - Some(ref url) => Uri::from_str(url).map_err(|e| error(format!("{}", e)))?, + Some(ref url) => Uri::from_str(url).map_err(|e| error(format!("{e}")))?, None => { println!("Usage: client "); return Ok(()); @@ -44,8 +44,8 @@ async fn run_client() -> io::Result<()> { // Second parameter is custom Root-CA store (optional, defaults to native cert store). let mut ca = match env::args().nth(2) { Some(ref path) => { - let f = fs::File::open(path) - .map_err(|e| error(format!("failed to open {}: {}", path, e)))?; + let f = + fs::File::open(path).map_err(|e| error(format!("failed to open {path}: {e}")))?; let rd = io::BufReader::new(f); Some(rd) } @@ -86,7 +86,7 @@ async fn run_client() -> io::Result<()> { let res = client .get(url) .await - .map_err(|e| error(format!("Could not get: {:?}", e)))?; + .map_err(|e| error(format!("Could not get: {e:?}")))?; println!("Status:\n{}", res.status()); println!("Headers:\n{:#?}", res.headers()); @@ -94,7 +94,7 @@ async fn run_client() -> io::Result<()> { .into_body() .collect() .await - .map_err(|e| error(format!("Could not get body: {:?}", e)))? + .map_err(|e| error(format!("Could not get body: {e:?}")))? .to_bytes(); println!("Body:\n{}", String::from_utf8_lossy(&body)); diff --git a/examples/server.rs b/examples/server.rs index 8f7803f..6cbcf45 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -23,7 +23,7 @@ use tokio_rustls::TlsAcceptor; fn main() { // Serve an echo service over HTTPS, with proper error handling. if let Err(e) = run_server() { - eprintln!("FAILED: {}", e); + eprintln!("FAILED: {e}"); std::process::exit(1); } } @@ -52,7 +52,7 @@ async fn run_server() -> Result<(), Box> { // Load private key. let key = load_private_key("examples/sample.rsa")?; - println!("Starting to serve on https://{}", addr); + println!("Starting to serve on https://{addr}"); // Create a TCP listener via tokio. let incoming = TcpListener::bind(&addr).await?; @@ -118,8 +118,8 @@ async fn echo(req: Request) -> Result>, hyper::Er // Load public certificate from file. fn load_certs(filename: &str) -> io::Result>> { // Open certificate file. - let certfile = fs::File::open(filename) - .map_err(|e| error(format!("failed to open {}: {}", filename, e)))?; + let certfile = + fs::File::open(filename).map_err(|e| error(format!("failed to open {filename}: {e}")))?; let mut reader = io::BufReader::new(certfile); // Load and return certificate. @@ -129,8 +129,8 @@ fn load_certs(filename: &str) -> io::Result>> { // Load private key from file. fn load_private_key(filename: &str) -> io::Result> { // Open keyfile. - let keyfile = fs::File::open(filename) - .map_err(|e| error(format!("failed to open {}: {}", filename, e)))?; + let keyfile = + fs::File::open(filename).map_err(|e| error(format!("failed to open {filename}: {e}")))?; let mut reader = io::BufReader::new(keyfile); // Load and return a single private key. diff --git a/src/config.rs b/src/config.rs index 3838261..db911b7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -93,16 +93,14 @@ impl ConfigBuilderExt for ConfigBuilder { match roots.add(cert) { Ok(_) => valid_count += 1, Err(err) => { - crate::log::debug!("certificate parsing failed: {:?}", err); + crate::log::debug!("certificate parsing failed: {err:?}"); invalid_count += 1 } } } crate::log::debug!( - "with_native_roots processed {} valid and {} invalid certs", - valid_count, - invalid_count + "with_native_roots processed {valid_count} valid and {invalid_count} invalid certs" ); if roots.is_empty() { crate::log::debug!("no valid native root CA certificates found"); diff --git a/tests/tests.rs b/tests/tests.rs index 91572bc..9e59038 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -29,7 +29,7 @@ fn wait_for_server(addr: &str) { } thread::sleep(time::Duration::from_millis(i * 100)); } - panic!("failed to connect to {:?} after 10 tries", addr); + panic!("failed to connect to {addr:?} after 10 tries"); } #[test] @@ -55,7 +55,7 @@ fn server() { let output = Command::new("curl") .arg("--insecure") .arg("--http1.0") - .arg(format!("https://{}", addr)) + .arg(format!("https://{addr}")) .output() .expect("cannot run curl"); @@ -87,7 +87,7 @@ fn custom_ca_store() { wait_for_server(addr); let rc = client_command() - .arg(format!("https://{}", addr)) + .arg(format!("https://{addr}")) .arg("examples/sample.pem") .output() .expect("cannot run client example");