diff --git a/proxmox-rest-server/src/formatter.rs b/proxmox-rest-server/src/formatter.rs index e31df5b81..709a6b1e0 100644 --- a/proxmox-rest-server/src/formatter.rs +++ b/proxmox-rest-server/src/formatter.rs @@ -141,18 +141,17 @@ impl OutputFormatter for ExtJsFormatter { } fn format_error(&self, err: Error) -> Response { - let message: String; let mut errors = HashMap::new(); - match err.downcast::() { + let message: String = match err.downcast::() { Ok(param_err) => { for (name, err) in param_err { errors.insert(name, err.to_string()); } - message = String::from("parameter verification errors"); + String::from("parameter verification errors") } - Err(err) => message = err.to_string(), - } + Err(err) => err.to_string(), + }; let result = json!({ "message": message, diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index d9e546bc1..b60282f80 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -978,8 +978,7 @@ impl WorkerTask { pub fn request_abort(&self) { let prev_abort = self.abort_requested.swap(true, Ordering::SeqCst); if !prev_abort { - // log abort one time - self.log_message("received abort request ...".to_string()); + self.log_message("received abort request ..."); // log abort only once } // noitify listeners let mut data = self.data.lock().unwrap(); diff --git a/src/bin/docgen.rs b/src/bin/docgen.rs index 5600da14a..82f2b2939 100644 --- a/src/bin/docgen.rs +++ b/src/bin/docgen.rs @@ -338,8 +338,7 @@ pub fn dump_api_schema( child["path"] = sub_path.into(); child["text"] = format!("{{{}}}", param_name).into(); - let mut children = Vec::new(); - children.push(child); + let children = vec![child]; data["children"] = children.into(); data["leaf"] = 0.into(); } diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index 62c32a123..ad700feeb 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -452,7 +452,7 @@ fn main() -> Result<(), Error> { proxmox_async::runtime::main(run()) } -fn get_sync_job(id: &String) -> Result { +fn get_sync_job(id: &str) -> Result { let (config, _digest) = sync::config()?; config.lookup("sync", id) @@ -536,12 +536,12 @@ pub fn complete_remote_datastore_group_filter( _arg: &str, param: &HashMap, ) -> Vec { - let mut list = Vec::new(); - - list.push("regex:".to_string()); - list.push("type:ct".to_string()); - list.push("type:host".to_string()); - list.push("type:vm".to_string()); + let mut list = vec![ + "regex:".to_string(), + "type:ct".to_string(), + "type:host".to_string(), + "type:vm".to_string(), + ]; list.extend( complete_remote_datastore_group(_arg, param) diff --git a/src/bin/proxmox-tape.rs b/src/bin/proxmox-tape.rs index cbc303a44..bf9791f1e 100644 --- a/src/bin/proxmox-tape.rs +++ b/src/bin/proxmox-tape.rs @@ -53,12 +53,12 @@ async fn get_backup_groups(store: &str) -> Result, Error> { // shell completion helper pub fn complete_datastore_group_filter(_arg: &str, param: &HashMap) -> Vec { - let mut list = Vec::new(); - - list.push("regex:".to_string()); - list.push("type:ct".to_string()); - list.push("type:host".to_string()); - list.push("type:vm".to_string()); + let mut list = vec![ + "regex:".to_string(), + "type:ct".to_string(), + "type:host".to_string(), + "type:vm".to_string(), + ]; if let Some(store) = param.get("store") { let groups = proxmox_async::runtime::block_on(async { get_backup_groups(store).await }); diff --git a/src/bin/proxmox_backup_debug/api.rs b/src/bin/proxmox_backup_debug/api.rs index 471240896..599425e8f 100644 --- a/src/bin/proxmox_backup_debug/api.rs +++ b/src/bin/proxmox_backup_debug/api.rs @@ -453,7 +453,8 @@ async fn ls( .noheader(true) .sortby("name", false); - let res = get_api_children(path.unwrap_or(String::from("/")), rpcenv).await?; + let path = path.unwrap_or_else(|| "".into()); + let res = get_api_children(path, rpcenv).await?; format_and_print_result_full( &mut serde_json::to_value(res)?, diff --git a/src/bin/proxmox_backup_debug/inspect.rs b/src/bin/proxmox_backup_debug/inspect.rs index 953dc738a..2e6160a94 100644 --- a/src/bin/proxmox_backup_debug/inspect.rs +++ b/src/bin/proxmox_backup_debug/inspect.rs @@ -119,7 +119,7 @@ fn inspect_chunk( let chunk_path = Path::new(&chunk); if digest.is_none() && use_filename_as_digest { - digest = Some(if let Some((_, filename)) = chunk.rsplit_once("/") { + digest = Some(if let Some((_, filename)) = chunk.rsplit_once('/') { String::from(filename) } else { chunk.clone() diff --git a/src/bin/proxmox_tape/encryption_key.rs b/src/bin/proxmox_tape/encryption_key.rs index d2f33475c..b62af2df4 100644 --- a/src/bin/proxmox_tape/encryption_key.rs +++ b/src/bin/proxmox_tape/encryption_key.rs @@ -205,7 +205,7 @@ async fn restore_key( bail!("cannot have both 'drive' and 'key(-file)' parameter set!"); } else if key.is_some() && key_file.is_some() { bail!("cannot have both 'key' and 'key-file' parameter set!"); - } else if !drive_passed && !key.is_some() && !key_file.is_some() { + } else if !drive_passed && key.is_none() && key_file.is_none() { bail!("one of either 'drive' or 'key' parameter must be set!"); } if !tty::stdin_isatty() { diff --git a/tests/worker-task-abort.rs b/tests/worker-task-abort.rs index 49372e2c5..eda86f01f 100644 --- a/tests/worker-task-abort.rs +++ b/tests/worker-task-abort.rs @@ -105,9 +105,8 @@ fn worker_task_abort() -> Result<(), Error> { }); let data = errmsg.lock().unwrap(); - match *data { - Some(ref err) => bail!("Error: {}", err), - None => {} + if let Some(ref err) = *data { + bail!("Error: {}", err) } Ok(())