Skip to content

Commit ab6bc77

Browse files
committed
Refactor timestamp formatting logic
1 parent 3f075ea commit ab6bc77

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,8 @@ where
440440
(secs / 60, "m ")
441441
};
442442

443-
let n = format!("{n:>3}");
444-
format!(
445-
"{timestamp}{unit} ",
446-
timestamp = self.styled(Style::new().dimmed(), n),
447-
unit = self.styled(Style::new().dimmed(), unit),
448-
)
443+
let timestamp = format!("{n:>3}");
444+
self.style_timestamp(timestamp, unit)
449445
}
450446

451447
fn format_timestamp_with_decimals(&self, start: std::time::Instant) -> String {
@@ -463,10 +459,14 @@ where
463459
(secs, "s ")
464460
};
465461

466-
let n = format!(" {n:.2}");
462+
let timestamp = format!(" {n:.2}");
463+
self.style_timestamp(timestamp, unit)
464+
}
465+
466+
fn style_timestamp(&self, timestamp: String, unit: &str) -> String {
467467
format!(
468468
"{timestamp}{unit} ",
469-
timestamp = self.styled(Style::new().dimmed(), n),
469+
timestamp = self.styled(Style::new().dimmed(), timestamp),
470470
unit = self.styled(Style::new().dimmed(), unit),
471471
)
472472
}

0 commit comments

Comments
 (0)