From 75f06f749cb605fb607f157ed69573799d3c2db8 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 5 May 2024 06:23:18 +0800 Subject: [PATCH] chore: fix typos and clippy (#379) --- assets/favicon.ico | Bin src/args.rs | 4 ++-- tests/auth.rs | 4 ++-- tests/http.rs | 6 +++--- tests/utils.rs | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) mode change 100755 => 100644 assets/favicon.ico diff --git a/assets/favicon.ico b/assets/favicon.ico old mode 100755 new mode 100644 diff --git a/src/args.rs b/src/args.rs index 9027051..f26dbca 100644 --- a/src/args.rs +++ b/src/args.rs @@ -301,7 +301,7 @@ impl Args { } if let Some(path) = matches.get_one::("serve-path") { - args.serve_path = path.clone() + args.serve_path.clone_from(path) } args.serve_path = Self::sanitize_path(args.serve_path)?; @@ -317,7 +317,7 @@ impl Args { args.path_is_file = args.serve_path.metadata()?.is_file(); if let Some(path_prefix) = matches.get_one::("path-prefix") { - args.path_prefix = path_prefix.clone(); + args.path_prefix.clone_from(path_prefix) } args.path_prefix = args.path_prefix.trim_matches('/').to_string(); diff --git a/tests/auth.rs b/tests/auth.rs index adaf63f..39e3b6d 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -299,14 +299,14 @@ fn auth_data( ) -> Result<(), Error> { let resp = reqwest::blocking::get(server.url())?; let content = resp.text()?; - let json = utils::retrive_json(&content).unwrap(); + let json = utils::retrieve_json(&content).unwrap(); assert_eq!(json["allow_delete"], serde_json::Value::Bool(false)); assert_eq!(json["allow_upload"], serde_json::Value::Bool(false)); let resp = fetch!(b"GET", server.url()) .basic_auth("user", Some("pass")) .send()?; let content = resp.text()?; - let json = utils::retrive_json(&content).unwrap(); + let json = utils::retrieve_json(&content).unwrap(); assert_eq!(json["allow_delete"], serde_json::Value::Bool(true)); assert_eq!(json["allow_upload"], serde_json::Value::Bool(true)); Ok(()) diff --git a/tests/http.rs b/tests/http.rs index 8ea5894..c2b0566 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -4,7 +4,7 @@ mod utils; use fixtures::{server, Error, TestServer, BIN_FILE}; use rstest::rstest; use serde_json::Value; -use utils::retrive_edit_file; +use utils::retrieve_edit_file; #[rstest] fn get_dir(server: TestServer) -> Result<(), Error> { @@ -238,7 +238,7 @@ fn get_file_newline_path(server: TestServer) -> Result<(), Error> { fn get_file_edit(server: TestServer) -> Result<(), Error> { let resp = fetch!(b"GET", format!("{}index.html?edit", server.url())).send()?; assert_eq!(resp.status(), 200); - let editable = retrive_edit_file(&resp.text().unwrap()).unwrap(); + let editable = retrieve_edit_file(&resp.text().unwrap()).unwrap(); assert!(editable); Ok(()) } @@ -247,7 +247,7 @@ fn get_file_edit(server: TestServer) -> Result<(), Error> { fn get_file_edit_bin(server: TestServer) -> Result<(), Error> { let resp = fetch!(b"GET", format!("{}{BIN_FILE}?edit", server.url())).send()?; assert_eq!(resp.status(), 200); - let editable = retrive_edit_file(&resp.text().unwrap()).unwrap(); + let editable = retrieve_edit_file(&resp.text().unwrap()).unwrap(); assert!(!editable); Ok(()) } diff --git a/tests/utils.rs b/tests/utils.rs index c987050..590ab78 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -26,7 +26,7 @@ macro_rules! fetch { #[allow(dead_code)] pub fn retrieve_index_paths(content: &str) -> IndexSet { - let value = retrive_json(content).unwrap(); + let value = retrieve_json(content).unwrap(); let paths = value .get("paths") .unwrap() @@ -47,8 +47,8 @@ pub fn retrieve_index_paths(content: &str) -> IndexSet { } #[allow(dead_code)] -pub fn retrive_edit_file(content: &str) -> Option { - let value = retrive_json(content)?; +pub fn retrieve_edit_file(content: &str) -> Option { + let value = retrieve_json(content)?; let value = value.get("editable").unwrap(); Some(value.as_bool().unwrap()) } @@ -60,7 +60,7 @@ pub fn encode_uri(v: &str) -> String { } #[allow(dead_code)] -pub fn retrive_json(content: &str) -> Option { +pub fn retrieve_json(content: &str) -> Option { let lines: Vec<&str> = content.lines().collect(); let line = lines.iter().find(|v| v.contains("DATA ="))?; let line_col = line.find("DATA =").unwrap() + 6;