From 451daea0aca8c241c6cc3e33aabf5aed57ddd0e8 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:42:17 +0800 Subject: [PATCH] Apply suggestions from new clippy lint `clippy::assigning_clones` (#382) * fix: clippy warnings * Additional fix * Write changelog --------- Co-authored-by: Krithic Kumar --- CHANGELOG.md | 1 + src/display/ui.rs | 2 +- src/display/ui_state.rs | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2b68a2..5ee803b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * Remove redundant imports #377 - @cyqsimon * CI: use GitHub API to exempt dependabot from changelog requirement #378 - @cyqsimon * Remove unnecessary logging synchronisation #381 - @cyqsimon +* Apply suggestions from new clippy lint clippy::assigning_clones #382 - @cyqsimon ## Added * CI: include generated assets in release archive #359 - @cyqsimon diff --git a/src/display/ui.rs b/src/display/ui.rs index e9df82d..7f7994c 100644 --- a/src/display/ui.rs +++ b/src/display/ui.rs @@ -33,7 +33,7 @@ where terminal.hide_cursor().unwrap(); let state = { let mut state = UIState::default(); - state.interface_name = opts.interface.clone(); + state.interface_name.clone_from(&opts.interface); state.unit_family = opts.render_opts.unit_family.into(); state.cumulative_mode = opts.render_opts.total_utilization; state diff --git a/src/display/ui_state.rs b/src/display/ui_state.rs index e01bbf3..95aa9d2 100644 --- a/src/display/ui_state.rs +++ b/src/display/ui_state.rs @@ -129,7 +129,9 @@ impl UIState { .or_default(); connection_data.total_bytes_downloaded += connection_info.total_bytes_downloaded; connection_data.total_bytes_uploaded += connection_info.total_bytes_uploaded; - connection_data.interface_name = connection_info.interface_name.clone(); + connection_data + .interface_name + .clone_from(&connection_info.interface_name); data_for_remote_address.total_bytes_downloaded += connection_info.total_bytes_downloaded; data_for_remote_address.total_bytes_uploaded += @@ -179,7 +181,7 @@ impl UIState { let proc_info = proc_info .cloned() .unwrap_or_else(|| ProcessInfo::new("", 0)); - connection_data.process_name = proc_info.name.clone(); + connection_data.process_name.clone_from(&proc_info.name); processes.entry(proc_info).or_default() };