Skip to content

Commit 8cdc5f8

Browse files
committed
Address clippy issues
1 parent ff76fb9 commit 8cdc5f8

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

src/ptp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl PtpHost {
446446
}
447447

448448
pub fn time_since_last_seen(&self, reference_time: Option<SystemTime>) -> Duration {
449-
let reference = reference_time.unwrap_or_else(|| SystemTime::now());
449+
let reference = reference_time.unwrap_or_else(SystemTime::now);
450450
reference.duration_since(self.last_seen).unwrap_or_default()
451451
}
452452

src/ui.rs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fn flatten_tree_nodes(nodes: &[TreeNode]) -> Vec<(&TreeNode, usize, bool)> {
4343
}
4444

4545
// Helper function to create a table row for a host
46+
#[allow(clippy::too_many_arguments)]
4647
fn create_host_row<'a>(
4748
host: &PtpHost,
4849
clock_identity_display: String,
@@ -154,12 +155,12 @@ fn create_host_row<'a>(
154155
}
155156

156157
// Helper function to create aligned label-value pairs
157-
fn create_aligned_field<'a>(
158+
fn create_aligned_field(
158159
label: String,
159160
value: String,
160161
label_width: usize,
161-
theme: &'a crate::themes::Theme,
162-
) -> Line<'a> {
162+
theme: &crate::themes::Theme,
163+
) -> Line {
163164
Line::from(vec![
164165
Span::styled(
165166
format!("{:width$}", label, width = label_width),
@@ -169,14 +170,14 @@ fn create_aligned_field<'a>(
169170
])
170171
}
171172

172-
fn create_aligned_field_with_vendor<'a>(
173+
fn create_aligned_field_with_vendor(
173174
label: String,
174175
value: String,
175176
vendor_info: String,
176177
label_width: usize,
177-
theme: &'a crate::themes::Theme,
178+
theme: &crate::themes::Theme,
178179
value_color: Color,
179-
) -> Line<'a> {
180+
) -> Line {
180181
Line::from(vec![
181182
Span::styled(
182183
format!("{:width$}", label, width = label_width),
@@ -733,18 +734,15 @@ fn render_host_details(f: &mut Frame, area: Rect, app: &mut App) {
733734
theme,
734735
));
735736

736-
match s.last_sync_origin_timestamp {
737-
Some(ts) => {
738-
for (k, v) in ts.format_common_samplerates("→ samples").iter() {
739-
details_text.push(create_aligned_field(
740-
format!("{}:", k),
741-
format!("{}", v),
742-
LABEL_WIDTH,
743-
theme,
744-
));
745-
}
737+
if let Some(ts) = s.last_sync_origin_timestamp {
738+
for (k, v) in ts.format_common_samplerates("→ samples").iter() {
739+
details_text.push(create_aligned_field(
740+
format!("{}:", k),
741+
v.to_string(),
742+
LABEL_WIDTH,
743+
theme,
744+
));
746745
}
747-
None => {}
748746
}
749747

750748
details_text.push(create_aligned_field(
@@ -754,18 +752,15 @@ fn render_host_details(f: &mut Frame, area: Rect, app: &mut App) {
754752
theme,
755753
));
756754

757-
match s.last_followup_origin_timestamp {
758-
Some(ts) => {
759-
for (k, v) in ts.format_common_samplerates("→ samples").iter() {
760-
details_text.push(create_aligned_field(
761-
format!("{}: ", k),
762-
format!("{}", v),
763-
LABEL_WIDTH,
764-
theme,
765-
));
766-
}
755+
if let Some(ts) = s.last_followup_origin_timestamp {
756+
for (k, v) in ts.format_common_samplerates("→ samples").iter() {
757+
details_text.push(create_aligned_field(
758+
format!("{}:", k),
759+
v.to_string(),
760+
LABEL_WIDTH,
761+
theme,
762+
));
767763
}
768-
None => {}
769764
}
770765
}
771766
PtpHostState::TimeReceiver(s) => {
@@ -1070,7 +1065,7 @@ fn format_system_time_ago(
10701065
system_time: std::time::SystemTime,
10711066
reference_time: Option<std::time::SystemTime>,
10721067
) -> String {
1073-
let reference = reference_time.unwrap_or_else(|| std::time::SystemTime::now());
1068+
let reference = reference_time.unwrap_or_else(std::time::SystemTime::now);
10741069
let elapsed = reference.duration_since(system_time).unwrap_or_default();
10751070

10761071
let elapsed_str = if elapsed.as_secs() < 1 {

0 commit comments

Comments
 (0)