From a2038f239bdb1d5ce012f09b8558ad7dd176a220 Mon Sep 17 00:00:00 2001 From: George Date: Sun, 18 Dec 2022 18:00:36 +0200 Subject: [PATCH] Fix future clippy linting warnings (#1423) --- src/cli/backup.rs | 16 ++++++++-------- src/cli/export.rs | 4 ++-- src/cli/import.rs | 4 ++-- src/cli/sql.rs | 8 ++++---- src/cli/start.rs | 2 +- src/net/head.rs | 2 +- src/net/rpc.rs | 2 +- src/net/version.rs | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cli/backup.rs b/src/cli/backup.rs index 0869475f..b295ea73 100644 --- a/src/cli/backup.rs +++ b/src/cli/backup.rs @@ -41,10 +41,10 @@ fn backup_http_to_file(matches: &clap::ArgMatches, from: &str, into: &str) -> Re // Parse the specified password let pass = matches.value_of("pass").unwrap(); // Set the correct source URL - let from = format!("{}/sync", from); + let from = format!("{from}/sync"); // Try to open the source http let mut from = Client::new() - .get(&from) + .get(from) .basic_auth(user, Some(pass)) .header(CONTENT_TYPE, TYPE) .send()? @@ -65,10 +65,10 @@ fn backup_file_to_http(matches: &clap::ArgMatches, from: &str, into: &str) -> Re // Try to open the source file let from = OpenOptions::new().read(true).open(from)?; // Set the correct output URL - let into = format!("{}/sync", into); + let into = format!("{into}/sync"); // Copy the data to the destination Client::new() - .post(&into) + .post(into) .basic_auth(user, Some(pass)) .header(CONTENT_TYPE, TYPE) .body(from) @@ -84,19 +84,19 @@ fn backup_http_to_http(matches: &clap::ArgMatches, from: &str, into: &str) -> Re // Parse the specified password let pass = matches.value_of("pass").unwrap(); // Set the correct source URL - let from = format!("{}/sync", from); + let from = format!("{from}/sync"); // Set the correct output URL - let into = format!("{}/sync", into); + let into = format!("{into}/sync"); // Try to open the source file let from = Client::new() - .get(&from) + .get(from) .basic_auth(user, Some(pass)) .header(CONTENT_TYPE, TYPE) .send()? .error_for_status()?; // Copy the data to the destination Client::new() - .post(&into) + .post(into) .basic_auth(user, Some(pass)) .header(CONTENT_TYPE, TYPE) .body(Body::new(from)) diff --git a/src/cli/export.rs b/src/cli/export.rs index 11cbeed6..2c55527f 100644 --- a/src/cli/export.rs +++ b/src/cli/export.rs @@ -18,10 +18,10 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> { let ns = matches.value_of("ns").unwrap(); let db = matches.value_of("db").unwrap(); // Set the correct export URL - let conn = format!("{}/export", conn); + let conn = format!("{conn}/export"); // Export the data from the database let mut res = Client::new() - .get(&conn) + .get(conn) .header(ACCEPT, "application/octet-stream") .basic_auth(user, Some(pass)) .header("NS", ns) diff --git a/src/cli/import.rs b/src/cli/import.rs index f4ca7a1a..8cbe6dbe 100644 --- a/src/cli/import.rs +++ b/src/cli/import.rs @@ -22,10 +22,10 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> { let ns = matches.value_of("ns").unwrap(); let db = matches.value_of("db").unwrap(); // Set the correct import URL - let conn = format!("{}/import", conn); + let conn = format!("{conn}/import"); // Import the data into the database let res = Client::new() - .post(&conn) + .post(conn) .header(ACCEPT, "application/octet-stream") .basic_auth(user, Some(pass)) .header("NS", ns) diff --git a/src/cli/sql.rs b/src/cli/sql.rs index adf35c48..b255b94b 100644 --- a/src/cli/sql.rs +++ b/src/cli/sql.rs @@ -19,7 +19,7 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> { // If we should pretty-print responses let pretty = matches.is_present("pretty"); // Set the correct import URL - let conn = format!("{}/sql", conn); + let conn = format!("{conn}/sql"); // Create a new terminal REPL let mut rl = Editor::<()>::new().unwrap(); // Load the command-line history @@ -57,8 +57,8 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> { let res = res.body(line).send(); // Get the request response match process(pretty, res) { - Ok(v) => println!("{}", v), - Err(e) => eprintln!("{}", e), + Ok(v) => println!("{v}"), + Err(e) => eprintln!("{e}"), } } // The user types CTRL-C @@ -71,7 +71,7 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> { } // There was en error Err(err) => { - eprintln!("Error: {:?}", err); + eprintln!("Error: {err:?}"); break; } } diff --git a/src/cli/start.rs b/src/cli/start.rs index 1b34d790..cfc2af3f 100644 --- a/src/cli/start.rs +++ b/src/cli/start.rs @@ -19,7 +19,7 @@ pub async fn init(matches: &clap::ArgMatches) -> Result<(), Error> { _ => unreachable!(), }; // Output SurrealDB logo - println!("{}", LOGO); + println!("{LOGO}"); // Setup the cli options config::init(matches); // Initiate environment diff --git a/src/net/head.rs b/src/net/head.rs index ccdfbffc..c21d623a 100644 --- a/src/net/head.rs +++ b/src/net/head.rs @@ -9,7 +9,7 @@ const SERVER: &str = "Server"; const VERSION: &str = "Version"; pub fn version() -> warp::filters::reply::WithHeader { - let val = format!("{}-{}", PKG_NAME, *PKG_VERSION); + let val = format!("{PKG_NAME}-{}", *PKG_VERSION); warp::reply::with::header(VERSION, val) } diff --git a/src/net/rpc.rs b/src/net/rpc.rs index c4dafb85..df0f88c1 100644 --- a/src/net/rpc.rs +++ b/src/net/rpc.rs @@ -284,7 +284,7 @@ impl Rpc { }, // Get the current server version "version" => match params.len() { - 0 => Ok(format!("{}-{}", PKG_NAME, *PKG_VERSION).into()), + 0 => Ok(format!("{PKG_NAME}-{}", *PKG_VERSION).into()), _ => return res::failure(id, Failure::INVALID_PARAMS).send(out, chn).await, }, // Run a full SurrealQL query against the database diff --git a/src/net/version.rs b/src/net/version.rs index 2c8940d2..299818e3 100644 --- a/src/net/version.rs +++ b/src/net/version.rs @@ -8,6 +8,6 @@ pub fn config() -> impl Filter Result { - let val = format!("{}-{}", PKG_NAME, *PKG_VERSION); + let val = format!("{PKG_NAME}-{}", *PKG_VERSION); Ok(warp::reply::with_status(val, http::StatusCode::OK)) }