From eb1df99c22dda45fec167b6e93db27844500c88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20M?= Date: Thu, 2 Feb 2023 16:18:11 +0100 Subject: [PATCH] fix: use inline args in all println and format (#83) --- src/fetch.rs | 2 +- src/main.rs | 14 +++++++------- src/router/route.rs | 2 +- src/router/routes.rs | 4 ++-- src/runtimes/manager.rs | 3 +-- src/runtimes/metadata.rs | 2 +- src/workers/worker.rs | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/fetch.rs b/src/fetch.rs index db7f0e47..baf78226 100644 --- a/src/fetch.rs +++ b/src/fetch.rs @@ -12,7 +12,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); /// using the Sha256. pub async fn fetch>(file: T) -> Result> { let client = reqwest::Client::new(); - let user_agent_value = format!("Wasm Workers Server/{}", VERSION); + let user_agent_value = format!("Wasm Workers Server/{VERSION}"); let body: Vec = client .get(file.as_ref()) diff --git a/src/main.rs b/src/main.rs index 3f8918fc..3aa87df3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,11 +87,11 @@ async fn not_found_html(req: &HttpRequest) -> HttpResponse { /// If no file is present, it will try to get a default "public/404.html" async fn find_static_html(uri_path: &str) -> Result { // File path. This is required for the wasm_handler as dynamic routes may capture static files - let file_path = ROOT_PATH.join(format!("public{}", uri_path)); + let file_path = ROOT_PATH.join(format!("public{uri_path}")); // A.k.a pretty urls. We may access /about and this matches to /about/index.html - let index_folder_path = ROOT_PATH.join(format!("public{}/index.html", uri_path)); + let index_folder_path = ROOT_PATH.join(format!("public{uri_path}/index.html")); // Same as before, but the file is located at ./about.html - let html_ext_path = ROOT_PATH.join(format!("public{}.html", uri_path)); + let html_ext_path = ROOT_PATH.join(format!("public{uri_path}.html")); if file_path.exists() { NamedFile::open_async(file_path).await @@ -226,28 +226,28 @@ async fn main() -> std::io::Result<()> { RuntimesCommands::List(list) => { if let Err(err) = list.run(sub).await { println!("❌ There was an error listing the runtimes from the repository"); - println!("👉 {}", err); + println!("👉 {err}"); exit(1); } } RuntimesCommands::Install(install) => { if let Err(err) = install.run(&args.path, sub).await { println!("❌ There was an error installing the runtime from the repository"); - println!("👉 {}", err); + println!("👉 {err}"); exit(1); } } RuntimesCommands::Uninstall(uninstall) => { if let Err(err) = uninstall.run(&args.path, sub) { println!("❌ There was an error uninstalling the runtime"); - println!("👉 {}", err); + println!("👉 {err}"); exit(1); } } RuntimesCommands::Check(check) => { if let Err(err) = check.run(&args.path) { println!("❌ There was an error checking the local runtimes"); - println!("👉 {}", err); + println!("👉 {err}"); exit(1); } } diff --git a/src/router/route.rs b/src/router/route.rs index feb8b49f..bacebb6f 100644 --- a/src/router/route.rs +++ b/src/router/route.rs @@ -65,7 +65,7 @@ impl Route { match Config::try_from_file(config_path) { Ok(c) => config = Some(c), Err(err) => { - eprintln!("{}", err); + eprintln!("{err}"); } } } diff --git a/src/router/routes.rs b/src/router/routes.rs index f5e28ea9..7e4964ac 100644 --- a/src/router/routes.rs +++ b/src/router/routes.rs @@ -93,7 +93,7 @@ mod tests { let build_route = |file: &str| -> Route { Route::new( Path::new("./tests/data/params"), - PathBuf::from(format!("./tests/data/params{}", file)), + PathBuf::from(format!("./tests/data/params{file}")), "", ) }; @@ -125,7 +125,7 @@ mod tests { let build_route = |file: &str| -> Route { Route::new( Path::new("./tests/data/params"), - PathBuf::from(format!("./tests/data/params{}", file)), + PathBuf::from(format!("./tests/data/params{file}")), "", ) }; diff --git a/src/runtimes/manager.rs b/src/runtimes/manager.rs index cf094d86..20e15647 100644 --- a/src/runtimes/manager.rs +++ b/src/runtimes/manager.rs @@ -26,8 +26,7 @@ pub fn init_runtime(project_root: &Path, path: &Path) -> Result Ok(Box::new(NativeRuntime::new(path.to_path_buf()))), _ => Err(anyhow!(format!( - "The '{}' extension does not have an associated runtime", - ext_as_str + "The '{ext_as_str}' extension does not have an associated runtime" ))), } } else { diff --git a/src/runtimes/metadata.rs b/src/runtimes/metadata.rs index 05d33a0d..e5cad75a 100644 --- a/src/runtimes/metadata.rs +++ b/src/runtimes/metadata.rs @@ -36,7 +36,7 @@ impl Repository { /// a result as the deserialization may fail. pub fn from_str(data: &str) -> Result { toml::from_str::(data).map_err(|err| { - println!("Err: {:?}", err); + println!("Err: {err}"); anyhow!("wws could not deserialize the repository metadata") }) } diff --git a/src/workers/worker.rs b/src/workers/worker.rs index 007dc65f..d864a680 100644 --- a/src/workers/worker.rs +++ b/src/workers/worker.rs @@ -89,7 +89,7 @@ impl Worker { let string_err = String::from_utf8(err_contents)?; if !string_err.is_empty() { - println!("Error: {}", string_err); + println!("Error: {string_err}"); } let contents: Vec = stdout