[pdm-devel] [PATCH proxmox-datacenter-manager 3/4] task_cache: Do field assigment inside initializer

Maximiliano Sandoval m.sandoval at proxmox.com
Mon Jan 13 13:08:30 CET 2025


Fixes:

warning: field assignment outside of initializer for an instance created with Default::default()
  --> server/src/task_cache.rs:78:17
   |
78 |                 params.source = Some(ListTasksSource::All);
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: consider initializing the variable with `pve_api_types::ListTasks { source: Some(ListTasksSource::All), since: Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60), ..Default::default() }` and removing relevant reassignments
  --> server/src/task_cache.rs:76:17
   |
76 |                 let mut params = ListTasks::default();
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
   = note: `#[warn(clippy::field_reassign_with_default)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 server/src/task_cache.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/server/src/task_cache.rs b/server/src/task_cache.rs
index 2d3c9b6..3ef24b1 100644
--- a/server/src/task_cache.rs
+++ b/server/src/task_cache.rs
@@ -73,12 +73,14 @@ async fn fetch_tasks(remote: &Remote) -> Result<Vec<TaskListItem>, Error> {
             // N+1 requests - we could use /cluster/tasks, but that one
             // only gives a limited task history
             for node in client.list_nodes().await? {
-                let mut params = ListTasks::default();
-                // Include running tasks
-                params.source = Some(ListTasksSource::All);
-                // TODO: How much task history do we want? Right now we just hard-code it
-                // to 7 days.
-                params.since = Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60);
+                let params = ListTasks {
+                    // Include running tasks
+                    source: Some(ListTasksSource::All),
+                    // TODO: How much task history do we want? Right now we just hard-code it
+                    // to 7 days.
+                    since: Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60),
+                    ..Default::default()
+                };
 
                 let list = client.get_task_list(&node.node, params).await?;
                 let mapped = map_tasks(list, &remote.id)?;
-- 
2.39.5





More information about the pdm-devel mailing list