Skip to content

Commit

Permalink
cleanup display of duration
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillFish8 committed Jul 31, 2021
1 parent ea3d3ce commit 0c3befa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,23 @@ fn humanize(time: Duration) -> String {
let (hours, minutes) = div_mod(minutes, 60);
let (days, hours) = div_mod(hours, 24);

let mut human = String::new();
let mut human = Vec::new();

if days != 0 {
human = format!("{} days, ", days);
human.push(format!("{} day(s)", days));
};

if hours != 0 {
human = format!("{}{} hours, ", human, hours);
human.push(format!("{} hour(s)", hours));
};

if minutes != 0 {
human = format!("{}{} minutes, ", human, minutes);
human.push(format!("{} minute(s)", minutes));
};

if seconds != 0 {
human = format!("{}{} seconds", human, seconds);
human.push(format!("{} second(s)", seconds));
};

human
human.join(", ")
}

0 comments on commit 0c3befa

Please sign in to comment.